mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Add compare_release fast path (#799)
Looking at the profile for tf-models-nightly after #789, `compare_release` is the single biggest item. Adding a fast path, we avoid paying the cost for padding releases with 0s when they are the same length, resulting in a 16% for this pathological case. Note that this mainly happens because tf-models-nightly is almost all large dev releases that hit the slow path. **Before**  **After**  ``` $ hyperfine --warmup 1 --runs 3 "target/profiling/main pip-compile -q scripts/requirements/tf-models-nightly.txt" "target/profiling/puffin pip-compile -q scripts/requirements/tf-models-nightly.txt" Benchmark 1: target/profiling/main pip-compile -q scripts/requirements/tf-models-nightly.txt Time (mean ± σ): 11.963 s ± 0.225 s [User: 11.478 s, System: 0.451 s] Range (min … max): 11.747 s … 12.196 s 3 runs Benchmark 2: target/profiling/puffin pip-compile -q scripts/requirements/tf-models-nightly.txt Time (mean ± σ): 10.317 s ± 0.720 s [User: 9.885 s, System: 0.404 s] Range (min … max): 9.501 s … 10.860 s 3 runs Summary target/profiling/puffin pip-compile -q scripts/requirements/tf-models-nightly.txt ran 1.16 ± 0.08 times faster than target/profiling/main pip-compile -q scripts/requirements/tf-models-nightly.txt ```
This commit is contained in:
parent
6c98ae9d77
commit
65efee1d76
1 changed files with 3 additions and 0 deletions
|
@ -2092,6 +2092,9 @@ impl<'source> FromPyObject<'source> for Version {
|
|||
/// Compare the release parts of two versions, e.g. `4.3.1` > `4.2`, `1.1.0` ==
|
||||
/// `1.1` and `1.16` < `1.19`
|
||||
pub(crate) fn compare_release(this: &[u64], other: &[u64]) -> Ordering {
|
||||
if this.len() == other.len() {
|
||||
return this.cmp(other);
|
||||
}
|
||||
// "When comparing release segments with different numbers of components, the shorter segment
|
||||
// is padded out with additional zeros as necessary"
|
||||
for (this, other) in this.iter().chain(std::iter::repeat(&0)).zip(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue