Coordinate and validate cached Python downloads #2772
<!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
Merging this PR will not alter performance
<details>
<summary>:warning: <b>8 benchmarks spent significant time in system calls</b></summary>
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
> - `discover_workspace_from_all_members
-install_wheel_many_files
-discover_workspace_from_all_members_with_excludes
-unpack_sdist_many_files
-run_python_version_synthetic_workspace
-resolve_warm_jupyter_universal
-resolve_warm_airflow
-resolve_warm_jupyter
</details>
✅ 69 untouched benchmarks ⏩ 35` skipped benchmarks[^skipped]
---
<sub>Comparing <code>zb/fix-managed-python-archive-cache</code> (f9ac43a) with <code>main</code> (c8e4086)</sub>
<a href="https://app.codspeed.io/astral-sh/uv-dev/branches/zb%2Ffix-managed-python-archive-cache?utm_source=github&utm_medium=comment-v2&utm_content=button">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://codspeed.io/pr-report/open-in-codspeed-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://codspeed.io/pr-report/open-in-codspeed-light.svg">
<img alt="Open in CodSpeed" src="https://codspeed.io/pr-report/open-in-codspeed-light.svg" width="169" height="32">
</picture>
</a>
[^skipped]: 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.
This is a little confusing
zanieb
zaniebot
Concurrent installations that share an empty Python archive cache can download the same archive independently, and completed responses enter the cache before any available checksum is checked. Lock individual cache misses and recheck the entry, verify available checksums before publishing downloads, and retain an open reader through extraction.
Related to astral-sh/uv-dev#2198.