Skip to content

Commit 34ac179

Browse files
authored
Merge pull request #14330 from lovesegfault/nix-s3-multipart
feat(libstore): add support for multipart s3 uploads
2 parents 0586370 + 3448d4f commit 34ac179

File tree

4 files changed

+268
-44
lines changed

4 files changed

+268
-44
lines changed

doc/manual/rl-next/s3-curl-implementation.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
synopsis: "Improved S3 binary cache support via HTTP"
3-
prs: [13823, 14026, 14120, 14131, 14135, 14144, 14170, 14190, 14198, 14206, 14209, 14222, 14223, 13752]
3+
prs: [13752, 13823, 14026, 14120, 14131, 14135, 14144, 14170, 14190, 14198, 14206, 14209, 14222, 14223, 14330, 14333, 14335, 14336, 14337, 14350, 14356, 14357, 14374, 14375, 14376, 14377, 14391, 14393, 14420, 14421]
44
issues: [13084, 12671, 11748, 12403]
55
---
66

@@ -18,9 +18,23 @@ improvements:
1818
The new implementation requires curl >= 7.75.0 and `aws-crt-cpp` for credential
1919
management.
2020

21-
All existing S3 URL formats and parameters remain supported, with the notable
22-
exception of multi-part uploads, which are no longer supported.
21+
All existing S3 URL formats and parameters remain supported, however the store
22+
settings for configuring multipart uploads have changed:
23+
24+
- **`multipart-upload`** (default: `false`): Enable multipart uploads for large
25+
files. When enabled, files exceeding the multipart threshold will be uploaded
26+
in multiple parts.
27+
28+
- **`multipart-threshold`** (default: `100 MiB`): Minimum file size for using
29+
multipart uploads. Files smaller than this will use regular PUT requests.
30+
Only takes effect when `multipart-upload` is enabled.
31+
32+
- **`multipart-chunk-size`** (default: `5 MiB`): Size of each part in multipart
33+
uploads. Must be at least 5 MiB (AWS S3 requirement). Larger chunk sizes
34+
reduce the number of requests but use more memory.
35+
36+
- **`buffer-size`**: Has been replaced by `multipart-chunk-size` and is now an alias to it.
2337

2438
Note that this change also means Nix now supports S3 binary cache stores even
25-
if build without `aws-crt-cpp`, but only for public buckets which do not
26-
require auth.
39+
if built without `aws-crt-cpp`, but only for public buckets which do not
40+
require authentication.

src/libstore/include/nix/store/s3-binary-cache-store.hh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,38 @@ struct S3BinaryCacheStoreConfig : HttpBinaryCacheStoreConfig
6161
> addressing instead of virtual host based addressing.
6262
)"};
6363

64+
const Setting<bool> multipartUpload{
65+
this,
66+
false,
67+
"multipart-upload",
68+
R"(
69+
Whether to use multipart uploads for large files. When enabled,
70+
files exceeding the multipart threshold will be uploaded in
71+
multiple parts, which is required for files larger than 5 GiB and
72+
can improve performance and reliability for large uploads.
73+
)"};
74+
75+
const Setting<uint64_t> multipartChunkSize{
76+
this,
77+
5 * 1024 * 1024,
78+
"multipart-chunk-size",
79+
R"(
80+
The size (in bytes) of each part in multipart uploads. Must be
81+
at least 5 MiB (AWS S3 requirement). Larger chunk sizes reduce the
82+
number of requests but use more memory. Default is 5 MiB.
83+
)",
84+
{"buffer-size"}};
85+
86+
const Setting<uint64_t> multipartThreshold{
87+
this,
88+
100 * 1024 * 1024,
89+
"multipart-threshold",
90+
R"(
91+
The minimum file size (in bytes) for using multipart uploads.
92+
Files smaller than this threshold will use regular PUT requests.
93+
Default is 100 MiB. Only takes effect when multipart-upload is enabled.
94+
)"};
95+
6496
/**
6597
* Set of settings that are part of the S3 URI itself.
6698
* These are needed for region specification and other S3-specific settings.

0 commit comments

Comments
 (0)