Skip to content

Reduce build metadata allocations and code size - #2723

Draft
charliermarsh wants to merge 8 commits into
mainfrom
charlie/codex-uv-build-metadata-size
Draft

charliermarsh wants to merge 8 commits into
mainfrom
charlie/codex-uv-build-metadata-size

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Generating and parsing build metadata creates intermediate allocations and uses several generic paths. Deserialize author/maintainer tables once, share table parsing for README/license fields, and share author/maintainer formatting. The shared value decoder retains ignored unsigned integers beyond i64::MAX and the original errors for out-of-range integers.

Render dependency strings directly into the final metadata lists, and use the backend's fixed py3-none-any tags without constructing a wheel filename for metadata-only hooks. Boxing the large TOML and validation error payloads also reduces the backend error enum from 112 to 88 bytes on x86_64.

Measurements of an earlier pinned revision. Hyperfine 2.0.0 measurements of 725b74bff → 55b34aaf9 used release builds of the complete CLI with rustc 1.99.0 (b940084d7 2026-09-28) on an AMD EPYC-Genoa Linux VM, pinned to four CPUs. Output went to /dev/null. The PR head at report preparation was 70dd423a1; the measured head was 55b34aaf9.

Commands invoke uv build-backend with the case-specific hook, --directory PROJECT, and a separate output directory. Synthetic projects vary dependency metadata, extras, contacts, scripts, and README size. Direct backend metadata, wheel, editable, and source-distribution hooks include project parsing, metadata generation, and output writes; dependency strings are not resolved or installed. Output directories are cleared outside wall time and RSS; OS pages are warm. No Python interpreter runs inside the measured backend hook. SOURCE_DATE_EPOCH and input timestamps are fixed.

Values are means, parent → head. Changes are (head / parent - 1) with 95% confidence intervals; negative values indicate a reduction.

Workload Wall time Change, 95% CI Peak RSS Change, 95% CI
wheel metadata / 0 dependencies / 0 extras / 0 contacts / 0 scripts / 0 README bytes 17.0 → 16.3 ms -4.09% [-10.91%, +1.06%] 19.35 → 19.09 MiB -1.34% [-1.89%, -0.73%]
editable metadata / 0 dependencies / 0 extras / 0 contacts / 0 scripts / 0 README bytes 16.0 → 15.8 ms -1.74% [-3.08%, -0.33%] 19.23 → 19.04 MiB -1.00% [-1.55%, -0.39%]
wheel metadata / 1,024 dependencies / 32 extras / 32 contacts / 0 scripts / 65,536 README bytes 18.0 → 17.8 ms -0.89% [-3.88%, +1.67%] 20.39 → 20.32 MiB -0.37% [-0.73%, +0.00%]
wheel metadata / 8,192 dependencies / 256 extras / 256 contacts / 256 scripts / 1,048,576 README bytes 30.5 → 29.8 ms -2.28% [-4.14%, -0.69%] 26.74 → 26.46 MiB -1.06% [-1.56%, -0.53%]
editable metadata / 8,192 dependencies / 256 extras / 256 contacts / 256 scripts / 1,048,576 README bytes 30.1 → 29.9 ms -0.66% [-1.60%, +0.30%] 26.68 → 26.48 MiB -0.75% [-1.09%, -0.41%]
wheel build / 8,192 dependencies / 256 extras / 256 contacts / 256 scripts / 1,048,576 README bytes 30.6 → 30.5 ms -0.31% [-1.29%, +0.83%] 27.23 → 27.31 MiB +0.28% [+0.00%, +0.52%]
source distribution build / 8,192 dependencies / 256 extras / 256 contacts / 256 scripts / 1,048,576 README bytes 45.7 → 44.4 ms -2.89% [-5.17%, -1.39%] 33.90 → 33.86 MiB -0.12% [-0.42%, +0.20%]
wheel metadata / 0 dependencies / 0 extras / 1,024 contacts / 0 scripts / 0 README bytes 20.3 → 20.7 ms +1.85% [+0.59%, +3.05%] 22.23 → 22.10 MiB -0.60% [-1.20%, +0.00%]

Each workload used ten comparison blocks with alternating revision order, one warmup followed by three measured runs per revision in each block (30 measurements per revision). The pointwise 95% percentile-bootstrap intervals use 20,000 resamples of paired block means and retain all samples. They estimate within-run uncertainty, not variation across machines, independent builds, or separate benchmark campaigns.

Three hook workloads reduced elapsed time by 1.74–2.89%. The contact-only metadata case increased it by 1.85%; the other four runtime intervals include zero. Four metadata-hook workloads reduced peak RSS by 0.19–0.28 MiB; the remaining four RSS intervals include zero. These results apply to the earlier pinned source pair shown above. RSS is Hyperfine's Linux wait4 peak, not an allocation count or summed simultaneous process-tree memory.

Earlier measurements

Earlier binary-size study:

On Linux x86_64 with Rust 1.99.0 and the stripped minimal-size profile, uv-build decreases from 3,301,624 to 3,287,160 bytes (14,464 bytes, 0.44%) against main at 725b74bff.

@astral-automations-bot astral-automations-bot Bot added internal A refactor or improvement that is not user-facing performance labels Oct 14, 2026
@codspeed

codspeed Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 69 untouched benchmarks
⏩ 35 skipped benchmarks1


Comparing charlie/codex-uv-build-metadata-size (70dd423) with main (8b67faf)

Open in CodSpeed

Footnotes

  1. 35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@astral-automations-bot
astral-automations-bot Bot force-pushed the charlie/codex-uv-build-metadata-size branch from 70dd423 to 9fe30be Compare October 19, 2026 21:50

This branch was successfully deployed

1 active deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant