Repository navigation
Conversation
2109b34 to
03d90fd
Compare
Merging this PR will improve performance by 47.45%1 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
| impl<'de> Deserialize<'de> for RequirementSourceWire { | ||
| fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| deserializer.deserialize_any(SourceVisitor) |
There was a problem hiding this comment.
[P3] Measure the benefit on flattened lockfile requirements
This replaces a derive with a manually maintained field list, duplicate tracking, and variant precedence, but the supplied timings are head-only JSON measurements. The lockfile consumer deserializes Requirement through #[serde(flatten)], which already buffers fields, while SourceField<T> retains per-field untagged buffering. Direct-source timings therefore do not establish the benefit on that path; the saved CodSpeed report covers unrelated hash-reader benchmarks. Please complete matched merge-base/head measurements using representative flattened TOML requirements or lockfile reads, including variability and early-match Git sources, to justify this additional maintenance cost.
Summary
Read the requirement-source map once. Serde buffers each recognized field independently and skips unknown fields. The first valid source wins in the existing precedence order. A duplicate or type mismatch rules out only the variants that need that field. Errors reading a recognized field, including invalid Unicode and excessive nesting, propagate.
Benchmarks
Release builds of the merge base (
4053abea3) and PR head (a1fa03a5d) on Linux x86-64 with Rust 1.99.0. Base and head times are means from the first pass. Each change in elapsed time has a paired 95% confidence interval.Among the complete lockfiles, the largest reduction was on the Pyx workspace, which has 564 package-metadata requirements. Neither the early-match Git requirement nor the small mixed URL/Git lock showed a conclusive change in either pass.
Lockfile inputs and timing method
The metadata cases deserialize a TOML
requires-distarray intoVec<Requirement>, including Serde’s flattened source. The HTTPX input uses its 12 registry requirements with names, specifiers, and markers. The single Git input uses the marked, revision-pinned requirement from the three-package mixed lock. HTTPX snapshot · Git fixtureEach complete file goes through
Lock::from_toml. All four used the canonical parser and round-tripped byte-for-byte on both revisions. The Pyx snapshot redacts aiohttp’s patch version. The input restores3.14.1using the matching sdist URL and hash in the Black snapshot. uv lockfile · Pyx snapshot · Black snapshotEach of two independently seeded passes used one pinned CPU and 120 randomized blocks per input. Each block timed the head and two baseline executions in balanced order. The timer covered parsing and dropping the value after warmup. File I/O, process startup, and output verification were outside the timer. Intervals use 10,000 paired bootstrap resamples. The Git baseline-against-itself control measured +0.50% in the first pass and −0.04% in the second.
Direct JSON parsing, CLI timings, and binary size
uv --helpThe stripped
uvexecutable shrank by 7,232 bytes, from 43,189,792 to 43,182,560.uvx(318,392 bytes) anduv-build(2,955,832 bytes) were byte-identical.These cases used two independently seeded passes on one pinned CPU with two baseline executions and one head execution per randomized block. Each JSON case used 240 blocks through
RequirementSource. Each CLI case used 600 blocks. Intervals use 4,000 paired bootstrap resamples. Theuv --helpbaseline-against-itself controls were −0.13% and +0.52%, with both intervals spanning zero.The offline resolver used the repository’s Trio input and metadata-only wheels reconstructed from the 38 pins and dependency edges in
test/requirements/compiled/trio.txt. Both binaries produced the same 38 pins and identical help text. Both revisions used the same checkout path and locked dependencies.uvanduvxused the release profile with self-update and no PGO.uv-buildused the minimal-size profile with LLD identical-code folding.Verification
All 68
uv-distribution-typeslibrary tests, package Clippy, and workspace formatting passed. The GitHub benchmark jobs uploaded results for this head. CPU simulation · Wall time