Experiment with bundled wheel metadata#20488
Draft
charliermarsh wants to merge 1 commit into
Draft
Conversation
charliermarsh
temporarily deployed
to
automations
July 16, 2026 21:45 — with
GitHub Actions
Inactive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backtracking-heavy warm resolutions can open thousands of tiny wheel-METADATA cache files. In the boto3 case, boto3/botocore alone require 1,903 files and 1.42 MB, of which roughly 1.1 MB is repeated HTTP-cache-policy trailers. Warm-page-cache measurements put opening/reading those files around 67 ms, versus roughly 1-2 ms for a sequential package-sized read.
This experiments with an additive, offline-only per-package metadata bundle. The first request loads a bundle through an Fx-hashed concurrent once-map; later requests reuse the buffer and an offset index. Wheel keys, exact request URLs, and decoded name/version are checked, and any bundle/key/URL/decode miss falls back to the existing per-wheel cache. Online freshness behavior is unchanged. A small benchmark packer is included so the cache can be seeded reproducibly.
PEP 658 metadata is per distribution, not per version, so this intentionally keeps one record per wheel rather than hydrating the version-level Simple metadata. The boto3/botocore bundles shrink the two directories from 1,424,072 B across 1,903 files to 725,861 B across two files.
Performance
Measured incrementally on the stale-cache and one-pass-prefetch changes, using profiling binaries and a prewarmed PyPI cache with every cached package bundled. All runs were offline
uv pip compile, Python 3.12, fixedUV_EXCLUDE_NEWER=2024-08-08T00:00:00Z,UV_CONCURRENT_CACHE_READS=4, CPUs 8-15, 10 warmups, and 40 alternating pairs. Every generated requirements file matched byte-for-byte.An 80-pair comparison of the combined changes against latest
mainindependently reproduced the large effects: boto3 -11.2% wall/-55.0% CPU and Airflow -5.5% wall/-14.8% CPU.This is explicitly experimental and not ready to merge: singleton-heavy Jupyter regresses, and a missing bundle is worse still because its first lookup adds an extra open. A production version needs either a bundle-presence manifest or resolver-driven threshold (for example, only after repeated attempts/batch prefetch), plus an atomic package-scoped writer and an artifact/metadata-hash guard for refreshed mutable indexes. The current packer/reader demonstrates the ceiling without changing online cache semantics.
The full
uv-clientunit suite (85 tests), strict clippy including tests, packer syntax check, formatting, and diff checks pass.