Commit ba86bab
Add opt-in join-the-flight ByteStream write dedup
N concurrent ByteStream Write streams for the same digest are N full
uploads over the wire and N full drains through the store stack. With the
new opt-in ByteStreamConfig.experimental_write_dedup, exactly one
concurrent upload per digest is elected the leading upload; concurrent
duplicates drain-and-discard their stream while waiting and are acked
with the REAPI early WriteResponse only once the leading upload durably
commits. Uploads of already-durable digests complete early after a single
existence check. If the leading upload fails or is cancelled, waiters
receive a retryable ABORTED via a send-on-drop guard and one retry
becomes the new leader. Resumed streams bypass dedup to preserve resume
semantics.
Waiters must drain their request stream: unread bytes would pin the
HTTP/2 connection flow-control window and deadlock a leading upload
sharing the connection (found by benchmark).
Measured (real gRPC stack, byte-verified, dedup off -> on): 228x256KiB
simultaneous same-digest uploads: server-received bytes 59.9MB -> 17.1MB
(3.5x), store updates 228 -> 1; 64x2MiB staggered burst: 136.5MB ->
8.8MB (15.5x), wall 42ms -> 3ms. Metrics group write_dedup:
flights_joined, early_completes, leader_failures, bytes_saved.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UXVtatcR9YMecBiu9RjwpC1 parent ddcb47e commit ba86bab
5 files changed
Lines changed: 676 additions & 4 deletions
File tree
- nativelink-config/src
- nativelink-service
- src
- tests
- nativelink-store/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
352 | 370 | | |
353 | 371 | | |
354 | 372 | | |
| |||
0 commit comments