uv
1deea745 - pep440-rs: use u32 instead of usize in Version representation

Commit
2 years ago
pep440-rs: use u32 instead of usize in Version representation I did this change for two reasons. Firstly, `usize` should generally only be used for something that is indexing memory. This is why it varies in size depending on the target. Since version numbers aren't really things that we use to index memory, we should be using a fixed size integer type. Secondly, I shrunk it down to `u32` because it doesn't really seem like we need to support version numbers bigger than 2^32. In theory, we could even take this down to 2^16 via `u16`, but that seems... within the realm of possibility? The actual reason to shrink it is to make `Version` take up less space, allocate less memory and (hopefully) increase the effectiveness of a small data optimization. Comparing this with the latest change there is a small improvement: $ hyperfine \ "./target/profiling/puffin-dev-jemalloc resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null" \ "./target/profiling/puffin-dev-u32 resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null" Benchmark 1: ./target/profiling/puffin-dev-jemalloc resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null Time (mean ± σ): 893.2 ms ± 19.5 ms [User: 14709.5 ms, System: 2463.3 ms] Range (min … max): 858.4 ms … 914.1 ms 10 runs Benchmark 2: ./target/profiling/puffin-dev-u32 resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null Time (mean ± σ): 866.9 ms ± 13.9 ms [User: 14745.4 ms, System: 2424.8 ms] Range (min … max): 850.1 ms … 896.4 ms 10 runs Summary './target/profiling/puffin-dev-u32 resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null' ran 1.03 ± 0.03 times faster than './target/profiling/puffin-dev-jemalloc resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null' The idea is that this might unlock better improvements later. (Spoiler alert: it didn't. But we keep this change anyway because it seems like good sense.)
Author
Committer
Parents
Loading