Commit 0597b51
committed
Optimize S3 transfer: streaming parallel download, multipart upload
Three performance improvements to the S3 transfer layer:
stat() now returns Content-Length alongside the existence check, so get()
can plan parallel range requests without issuing a second HEAD request.
parallelGet() no longer buffers each 32 MiB chunk into a Go []byte via
io.ReadAll. Workers now send the open http.Response body to a per-chunk
channel; the serial writer streams each body directly into the pipe with
io.Copy. In-flight chunks wait in kernel TCP receive buffers rather than
Go heap, eliminating the ~256 MiB of allocation pressure and GC work that
occurred during every download.
put() uses S3 multipart upload for objects larger than 64 MiB (8 parts
in parallel, 64 MiB each). Smaller objects continue to use single-part PUT.
Parallel part uploads match the throughput of parallel range GETs. The
upload is aborted automatically on any part failure.1 parent fc41d39 commit 0597b51
2 files changed
Lines changed: 234 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
99 | 100 | | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
126 | | - | |
| 128 | + | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| |||
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 153 | + | |
| 154 | + | |
154 | 155 | | |
155 | | - | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
0 commit comments