Skip to content

Reuse cached small files during wheel extraction - #21375

Closed
charliermarsh wants to merge 2 commits into
mainfrom
charlie/avoid-small-file-cache-writes
Closed

charliermarsh wants to merge 2 commits into
mainfrom
charlie/avoid-small-file-cache-writes

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

When a small wheel file already exists in the content-addressed cache, we currently write out another copy during extraction, delete it, and replace it with a hardlink. This prototype buffers files up to 64 KiB and links existing objects directly into the extracted archive, avoiding the redundant write.

Streaming extraction retains at most 1 MiB of file contents and 1,024 files until the central directory supplies executable permissions. Larger files and exhausted budgets keep streaming; cache misses and failed hardlinks write a private copy. RECORD stays private, and ZIP checksums and sizes are still validated.

We compared against #21327 on Linux/ext4 using optimized builds, preselected wheels, and localhost HTTP. Each cell is the median of eight runs per binary in alternating ABBA/BAAB blocks, with baseline → prototype wall time. Installed paths, contents, and permissions matched across all 192 runs.

Workload Input Empty cache Existing file objects
100 small synthetic wheels Local 0.599 → 0.611 s (+2.1%) 0.612 → 0.524 s (-14.5%)
100 small synthetic wheels HTTP 0.763 → 0.530 s (-30.5%) 0.684 → 0.534 s (-22.0%)
AnyIO, NumPy, SymPy Local 0.495 → 0.435 s (-12.1%) 0.498 → 0.434 s (-12.8%)
AnyIO, NumPy, SymPy HTTP 0.913 → 0.922 s (+0.9%) 0.923 → 0.890 s (-3.6%)
Jupyter (96 wheels) Local 2.354 → 2.431 s (+3.2%) 3.437 → 2.808 s (-18.3%)
Jupyter (96 wheels) HTTP 3.837 → 4.187 s (+9.1%) 3.722 → 3.837 s (+3.1%)

The existing-object case retains only files-v0 and forces wheel extraction again, isolating the reuse opportunity. Ordinary warm installs can reuse the unpacked archive directly. These are exploratory timings with substantial variation in several cases, especially the synthetic HTTP workload.

The clearest gain was local Jupyter extraction with existing objects: 18% lower median time, improvement in all four paired blocks, and 42% fewer reported filesystem output blocks. HTTP Jupyter was slower both with an empty cache and with existing objects, so this remains a draft while we evaluate the streaming tradeoff.

Base automatically changed from charlie/dirhash-all-files to main August 31, 2026 13:28
@charliermarsh
charliermarsh force-pushed the charlie/avoid-small-file-cache-writes branch from 0f66630 to e7eafd3 Compare August 31, 2026 13:33
@astral-sh-bot

astral-sh-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 3
  • Removed tests: 0
  • Changed suites: 1
uv::build: +3 / -0

Added:

  • uv::build::cache::cached_streaming_extraction_limits_buffered_bytes
  • uv::build::cache::cached_streaming_extraction_limits_buffered_files
  • uv::build::cache::small_files_reuse_cached_objects_during_extraction

Removed: none

This branch was previously deployed

1 inactive deployment
automations — e7eafd3d Deployed Aug 31, 2026 by charliermarsh via review / security review #45524
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.

1 participant