Technology
Pull request for uv speeds up Python package installations by reusing memory buffers
A performance optimization in the uv package manager reduces cold installation times by reusing a single buffer during streaming extraction.
The short version
- A pull request for Astral's uv project optimizes wheel extraction by reusing one 64 KiB buffer per wheel rather than allocating a new buffer for every file copied and hashed.
- Benchmark tests showed cold installation time improvements ranging from 2.6% to 9.5% across several packages, including PyTorch, NumPy, SymPy, and AnyIO.
- Cached installations and local-wheel controls showed no consistent change in performance.
Key facts
- A pull request in the uv repository reuses a single 64 KiB buffer for file copying and content hashing during streaming extraction.[Hacker News]
- Buffer allocations for hashing during PyTorch CPU wheel extraction dropped from 11,120 to one during testing.[Hacker News]
- Cold installation benchmarks demonstrated time reductions of 2.6% for AnyIO, 7.8% for PyTorch CPU, 8.3% for SymPy, and 9.5% for NumPy.[Hacker News]
- Cold installation times for a 14-package environment with concurrency four fell from 6.95 seconds to 6.47 seconds.[Hacker News]
- Benchmarking was performed on Linux/ext4 on an eight-CPU AMD EPYC-Milan virtual machine running Python 3.12.13 and Rust 1.98.0.[Hacker News]
What remains uncertain
- Whether performance improvements observed in Linux/ext4 virtual machine benchmarks translate consistently across other operating systems or hardware setups is unconfirmed.[Hacker News]
Sources
- uv: Deduplicate all files in the wheel cacheHacker News