Skip to content

Reuse dependency-group Python markers - #244

Draft
zaniebot wants to merge 1 commit into
mainfrom
zb/bughuntperf/223-group-python-markers
Draft

zaniebot wants to merge 1 commit into
mainfrom
zb/bughuntperf/223-group-python-markers

Conversation

@zaniebot

@zaniebot zaniebot commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

Flattening a dependency group with requires-python rebuilds the same RequiresPython and marker tree for every local or inherited requirement. Construct the marker once per configured group and combine it with each requirement's existing marker. This avoids repeated range construction without changing group bounds or requirement order.

Hyperfine 2.0.0 measurements of 1f85ea101 → 948c8f57c 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 supplied interpreter was CPython 3.12.13.

uv lock --no-index --find-links includes project parsing, group flattening, resolution, and serialization. Synthetic dependency groups have simple Python bounds or specifiers excluding 64 even-numbered Python 3.13 patch releases. Empty, populated, unconfigured, and inherited-group inputs are included. In the inherited case, a base group declares 256 requirements and an outer group includes the base twice and declares 256 of its own; the lock records 512 distinct outer-group requirements. Group Python markers use the bounding range, so the internal exclusions are not preserved as marker holes. Each command starts a fresh process. OS pages, local wheel metadata, and interpreter-query caches are warm. The lockfile is removed outside the measured interval.

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
1 group / 0 requirements / no group Python bound 22.4 → 22.5 ms +0.28% [-1.91%, +2.48%] 35.06 → 34.98 MiB -0.24% [-0.40%, -0.07%]
1 group / 0 requirements / simple Python bounds 22.2 → 23.0 ms +3.79% [+0.76%, +7.46%] 35.00 → 35.07 MiB +0.19% [-0.14%, +0.52%]
512 groups / 0 requirements / simple Python bounds 80.3 → 72.2 ms -10.02% [-26.61%, +1.95%] 51.83 → 51.99 MiB +0.31% [+0.01%, +0.61%]
512 groups / 0 requirements / 64 Python exclusions 85.7 → 154.9 ms +80.82% [+73.58%, +86.49%] 55.12 → 54.98 MiB -0.25% [-0.40%, -0.08%]
1 group / 1 requirement / simple Python bounds 23.7 → 23.4 ms -1.21% [-2.96%, +0.98%] 36.68 → 36.71 MiB +0.09% [-0.20%, +0.41%]
1 group / 32 requirements / simple Python bounds 32.7 → 32.7 ms +0.11% [-1.72%, +1.81%] 40.37 → 40.28 MiB -0.24% [-0.63%, +0.11%]
1 group / 2,048 requirements / simple Python bounds 318.5 → 314.2 ms -1.35% [-3.55%, +1.17%] 135.44 → 135.02 MiB -0.31% [-3.62%, +3.36%]
1 group / 32 requirements / 64 Python exclusions 41.1 → 33.2 ms -19.11% [-33.32%, -7.91%] 40.27 → 40.39 MiB +0.29% [-0.21%, +0.83%]
1 group / 2,048 requirements / 64 Python exclusions 604.7 → 315.6 ms -47.82% [-49.97%, -46.20%] 133.61 → 135.08 MiB +1.10% [-1.50%, +3.88%]
2 groups / 256 base + 256 own requirements / base included twice / 64 Python exclusions 155.7 → 121.2 ms -22.15% [-25.30%, -18.30%] 72.36 → 73.42 MiB +1.47% [-1.29%, +4.70%]
1 group / 2,048 requirements / no group Python bound 279.0 → 278.5 ms -0.19% [-4.00%, +4.21%] 132.11 → 132.44 MiB +0.25% [-3.85%, +5.04%]

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.

For the empty-group cases, wall time rose 80.82% with 512 groups and 64 exclusions, and 3.79% with one group and simple bounds. It fell 19.11–47.82% in the three populated or inherited cases with exclusions; the other six runtime intervals include zero. Peak RSS fell in two cases, rose in one, and was inconclusive in the other eight. These are complete-command results and do not isolate marker construction. RSS is Hyperfine's Linux wait4 peak, not an allocation count or summed simultaneous process-tree memory.

Earlier measurements

Earlier benchmark study:

The earlier paired component study also exposed an empty-group regression: its head a58f5c41 took 10.4795× as long as its base c8d39cb1, with a pointwise 95% interval of [10.3688, 10.5913]. Descriptive arithmetic means were about 164 ns and 1.714 µs per call. In that source pair, moving marker construction outside the requirement loop made it run even when there were no requirements. That regression was a landing concern in the earlier study; those measurements do not establish an effect for a subsequent fix.

The complete prespecified comparison used base c8d39cb1 and head a58f5c41, isolated Rust 1.97.1 release builds, a common lockfile and study overlay, and a dedicated 16-vCPU x86-64 Linux VM. The normalized source pair differs only in crates/uv-workspace/src/dependency_groups.rs. Ratios are head/base; intervals are pointwise 95% Student-t intervals for the mean paired log ratio, exponentiated.

Case A/B pairs Head/base [95% interval] Outcome
real/uv — — A/A-inconclusive
control/unconfigured-empty 24 1.012112 [0.985185, 1.039775] Within ±5%
control/unconfigured-32 12 1.018574 [0.959172, 1.081654] Inconclusive
control/configured-empty 12 10.479489 [10.368837, 10.591321] At least 5% slower
control/simple-singleton — — A/A-inconclusive
control/exclusions-singleton — — A/A-inconclusive
control/simple-32 12 0.584685 [0.535612, 0.638254] At least 5% faster
control/exclusions-32 12 0.345408 [0.336258, 0.354807] At least 5% faster
control/exclusions-2048 — — A/A-inconclusive
control/included-overlap — — A/A-inconclusive
control/duplicate-includes 12 0.715561 [0.677541, 0.755713] At least 5% faster
control/included-empty-adverse — — A/A-inconclusive

Each workload began with 12 fresh-process A/A paired blocks. The fixed noise rule selected 12 or 24 A/B pairs, or left the workload A/A-inconclusive with no head/base estimate. The intervals are not simultaneous. This is a warm production-API component measurement from a preparsed PyProjectToml; it includes group collection and flattening, requirement parsing, marker construction and composition, and result allocation and destruction. It excludes TOML parsing. The authentic uv manifest was inconclusive, so this does not establish a cold-process or whole-command speedup. uv-dev#1572 and uv-dev#1578 remain the separate source-requirements and project-lock benchmark owners.

The recorded samples, complete report, replay, and exact source overlays are retained in uv-dev#2259.

@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/223-group-python-markers branch from 2184736 to deaeb5d Compare July 27, 2026 19:53
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/223-group-python-markers branch from deaeb5d to a58f5c4 Compare August 7, 2026 11:32
@zaniebot zaniebot added priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. size:1 Small: one localized behavior with straightforward tests or documentation checks. performance risk:1 Negligible risk of localized mistakes that are obvious and easy to correct. labels Sep 9, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/223-group-python-markers branch from a58f5c4 to 948c8f5 Compare October 7, 2026 23:55
@codspeed

codspeed Bot commented Oct 8, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by ×9.2

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 11 improved benchmarks
✅ 43 untouched benchmarks
🆕 2 new benchmarks
⏩ 35 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ WallTime unzip_wheel_many_files 371 ms 12.3 ms ×30
⚡ WallTime install_wheel_many_files 385 ms 13.7 ms ×28
⚡ WallTime prepare_wheel_many_files 383.4 ms 14.9 ms ×26
⚡ WallTime unpack_sdist_many_files 317.2 ms 36.9 ms ×8.6
⚡ WallTime resolve_warm_jupyter_universal 87.6 ms 11.7 ms ×7.5
⚡ WallTime resolve_warm_jupyter 17.4 ms 2.5 ms ×7
⚡ WallTime discover_workspace_from_all_members_with_excludes 52.7 ms 8.3 ms ×6.3
⚡ WallTime discover_workspace_from_all_members 50.5 ms 8 ms ×6.3
⚡ WallTime run_python_version_synthetic_workspace 268.4 ms 43.3 ms ×6.2
⚡ WallTime resolve_warm_airflow 233.2 ms 41.7 ms ×5.6
⚡ WallTime hash_sha256 1,165.6 µs 407.8 µs ×2.9
🆕 WallTime flatten_dependency_group_with_python_markers N/A 168.2 µs N/A
🆕 Simulation flatten_dependency_group_with_python_markers N/A 3.9 ms N/A

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing zb/bughuntperf/223-group-python-markers (948c8f5) with main (b7c8c62)2

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. ↩

  2. No successful run was found on main (00e49e7) during the generation of this report, so b7c8c62 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

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

performance priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. risk:1 Negligible risk of localized mistakes that are obvious and easy to correct. size:1 Small: one localized behavior with straightforward tests or documentation checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants