Skip to content

perf(reconstruction): stream decompressed chunks as they arrive - #1080

Draft
seanses wants to merge 1 commit into
mainfrom
di/stream-chunks-incrementally
Draft

seanses wants to merge 1 commit into
mainfrom
di/stream-chunks-incrementally

Conversation

@seanses

@seanses seanses commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@seanses
seanses force-pushed the di/stream-chunks-incrementally branch from a256b51 to 99c5d46 Compare November 4, 2026 19:29
@seanses
seanses force-pushed the di/stream-chunks-incrementally branch from 99c5d46 to 5296df0 Compare November 4, 2026 20:35
@seanses

seanses commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Measurements

macOS laptop (12 cores, about 17MB/s simulating slower network, 190ms RTT), released hf_xet 1.7.0 and #1061 (9d234ab) against this branch (5296df0), each built with maturin develop --release, default config. Streams are opened with download_stream through huggingface/huggingface_hub#5165 (eb02168a). Each run is in a fresh process, with the builds interleaved (5 runs for first chunks, 3 for whole files):

1.7.0 #1061 this branch
First chunk of a stream (fineweb-edu Parquet, 1.9GB) 18.1 to 65.8s, 67MB, 362 to 684MB RSS 3.25 to 3.68s, 2MB, 71 to 73MB RSS 2.18 to 2.36s, 16KB, 64MB RSS
First chunk of a stream (cc3m-wds tar, 488MB) 12.0 to 69.5s, 67MB, 271 to 557MB RSS 3.22 to 3.48s, 2MB, 72MB RSS 2.87 to 3.07s, 8KB, 66 to 67MB RSS
HfFileSystem (huggingface/huggingface_hub#5165), block_size=0, first 4 bytes of the tar 12.5 to 15.7s, 336 to 390MB RSS 3.45 to 3.56s, 80 to 82MB RSS 3.12 to 3.42s, 72 to 73MB RSS
Whole Parquet stream 123.1 to 236.9s, 1.45 to 1.88GB peak RSS not measured 123.9 to 128.9s, 1.44 to 1.69GB peak RSS
Whole tar stream 37.8 to 54.3s, 506 to 596MB peak RSS not measured 36.2 to 44.7s, 466 to 483MB peak RSS
  • The process uses about 60MB before a stream starts, so the RSS at the first chunk is mostly the data received before it is handed to the reader. On 1.7.0 that is the whole first term plus the blocks downloading alongside it.
  • Whole-file time and peak memory do not change: they depend on the link and on the download buffers, not on when chunks are handed to the reader.

@XciD

XciD commented Nov 10, 2026

Copy link
Copy Markdown
Member

Ran this PR (5296df0) on a shaped link: Linux, netem 17MB/s and 190ms RTT, default config, download_stream from 0, fresh process per run.

One case where it is slower than #1061: the first chunk of the cc3m-wds tar (488MB) takes 6.5 to 7.9s in 4 runs out of 5 (3.5s in the fifth), against 3.7 to 4.2s with #1061. In the logs, the first get_reconstruction call covers the whole file: the 256MB first block is extended to the end of the range, so 901 terms in one response. The headers arrive at about 2s in every run, but the call completes at 2.5s or 5.5s. A direct call for the same range from the same namespace takes 1.6s, so I don't know where the extra 3s goes.

Stacking the 2MB first block from #1061 on top brings the tar down to 2.4 to 3.0s, but the fineweb-edu Parquet shard then takes 29 to 37s to reach 64MB instead of 19 to 22s, so not as is.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants