Skip to content

Improve distribution id performance#18486

Merged
konstin merged 2 commits intomainfrom
konsti/maybe-perf-dist-id
Mar 15, 2026
Merged

Improve distribution id performance#18486
konstin merged 2 commits intomainfrom
konsti/maybe-perf-dist-id

Conversation

@konstin
Copy link
Copy Markdown
Member

@konstin konstin commented Mar 15, 2026

Improve the performance for #18373.

$ hyperfine --warmup 3 --runs 30 \
    '/tmp/uv-0-baseline lock --project /home/konsti/projects/airflow' \
    '/tmp/uv-1-or-insert-with lock --project /home/konsti/projects/airflow' \
    '/tmp/uv-2-single-lookup lock --project /home/konsti/projects/airflow' \

Benchmark 1: /tmp/uv-0-baseline lock --project /home/konsti/projects/airflow
Time (mean ± σ):     147.1 ms ±  10.1 ms    [User: 108.4 ms, System: 23.6 ms]
Range (min … max):   130.5 ms … 165.9 ms    30 runs

Benchmark 2: /tmp/uv-1-or-insert-with lock --project /home/konsti/projects/airflow
Time (mean ± σ):     141.3 ms ±   7.3 ms    [User: 106.3 ms, System: 21.3 ms]
Range (min … max):   131.5 ms … 160.6 ms    30 runs

Benchmark 3: /tmp/uv-2-single-lookup lock --project /home/konsti/projects/airflow
Time (mean ± σ):     139.6 ms ±   7.3 ms    [User: 104.7 ms, System: 21.8 ms]
Range (min … max):   128.3 ms … 160.9 ms    30 runs

Summary
/tmp/uv-2-single-lookup lock --project /home/konsti/projects/airflow ran
 1.01 ± 0.07 times faster than /tmp/uv-1-or-insert-with lock --project /home/konsti/projects/airflow
 1.05 ± 0.09 times faster than /tmp/uv-0-baseline lock --project /home/konsti/projects/airflow

@konstin konstin force-pushed the konsti/maybe-perf-dist-id branch from 138bffe to 2210fe3 Compare March 15, 2026 16:49
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 15, 2026

Merging this PR will improve performance by 7.88%

⚡ 1 improved benchmark
✅ 4 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime resolve_warm_airflow 533.5 ms 494.5 ms +7.88%

Comparing konsti/maybe-perf-dist-id (9c7629c) with main (ea786e5)

Open in CodSpeed

@konstin konstin added the performance Potential performance improvement label Mar 15, 2026
Within a single fork, the same `(name, version)` always resolves to the
same distribution, so we can skip constructing the `FilePin` (which
involves `to_owned()` and two `distribution_id()` calls) when the entry
already exists.
@konstin konstin force-pushed the konsti/maybe-perf-dist-id branch from 2210fe3 to f4e3cc5 Compare March 15, 2026 17:54
@konstin konstin changed the title Maybe perf Improve distribution id performance Mar 15, 2026
Replace separate `metadata_id()` + `get()` calls with a single
`get_with_metadata_id()` lookup. Borrow the `DistributionId` from the
pin instead of cloning, and defer error string formatting to the error
path.
@konstin konstin force-pushed the konsti/maybe-perf-dist-id branch from f4e3cc5 to 9c7629c Compare March 15, 2026 18:27
@konstin konstin marked this pull request as ready for review March 15, 2026 18:28
@konstin konstin requested a review from charliermarsh March 15, 2026 18:28
@konstin konstin merged commit 5f77df8 into main Mar 15, 2026
54 checks passed
@konstin konstin deleted the konsti/maybe-perf-dist-id branch March 15, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants