refactor: replace InternedString with Cow in IndexPackage
What does this PR try to resolve?
ref https://github.com/rust-lang/cargo/issues/14834
As described in the issue, we want to move IndexPackage into cargo-util-schemas. However, it contains InternedString fields, which we don't want to expose as part of the public API. This PR replaces InternedString with Cow.
How should we test and review this PR?
It shouldn't change or break any tests.
Additional information
None
r? @ehuss
rustbot has assigned @ehuss. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
I would recommend at least doing some benchmarking using our bench suite. https://github.com/rust-lang/cargo/tree/master/benches contains some documentation, and particularly the resolve bench. cargo bench -p benchsuite --bench resolve is a good place to start (while you are figuring out how to run the benchmarks you can do an individual workspace like resolve_ws/rust to speed things up), and Comparing implementation explains how you can do a comparison report against master.
WIP: I need to do more tests
I’ve tested this change several times using the resolve_ws/rust benchmark suite.
My test env:
Model Name: MacBook Pro
Chip: Apple M4 Max
Total Number of Cores: 14 (10 performance and 4 efficiency)
Memory: 36 GB
Test result:
master commit: HEAD is now at c2c636a6d fix(toml): Remove workaround for rustc frontmatter support (#15570)
master: cargo bench -p benchsuite --bench resolve -- resolve_ws/rust --save-baseline master --measurement-time 50 --sample-size 500
patch: cargo bench -p benchsuite --bench resolve -- resolve_ws/rust --baseline master --measurement-time 50 --sample-size 500
First round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 98.328 ms | +0.9865% | 20 (4.00%) - 16 high mild, 4 high severe |
| resolve_ws/rust-ws-inherit | 97.151 ms | -0.5031% | 25 (5.00%) - 19 high mild, 6 high severe |
Second round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 97.223 ms | +0.7313% | 11 (2.20%) - 9 high mild, 2 high severe |
| resolve_ws/rust-ws-inherit | 96.244 ms | +0.1513% | 11 (2.20%) - 10 high mild, 1 high severe |
Third round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 96.765 ms | +1.2520% | 14 (2.80%) - 11 high mild, 3 high severe |
| resolve_ws/rust-ws-inherit | 96.107 ms | +0.7632% | 13 (2.60%) - 12 high mild, 1 high severe |
Fourth round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 96.226 ms | -0.8911% | 9 (1.80%) - 7 high mild, 2 high severe |
| resolve_ws/rust-ws-inherit | 95.999 ms | -0.7607% | 18 (3.60%) - 14 high mild, 4 high severe |
I’ve tested this change several times using the resolve_ws/rust benchmark suite.
My test env:
Model Name: MacBook Pro
Chip: Apple M4 Max
Total Number of Cores: 14 (10 performance and 4 efficiency)
Memory: 36 GB
Test result:
master commit: HEAD is now at c2c636a6d fix(toml): Remove workaround for rustc frontmatter support (#15570)
master: cargo bench -p benchsuite --bench resolve -- resolve_ws/rust --save-baseline master --measurement-time 50 --sample-size 500
patch: cargo bench -p benchsuite --bench resolve -- resolve_ws/rust --baseline master --measurement-time 50 --sample-size 500
First round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 91.910 ms | -0.9313% | 31 (6.20%) - 14 high mild, 16 high severe |
| resolve_ws/rust-ws-inherit | 92.021 ms | +0.7503% | 43 (8.60%) - 14 high mild, 22 high severe |
Second round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 92.142 ms | +1.7303% | 33 (6.60%) - 10 high mild, 23 high severe |
| resolve_ws/rust-ws-inherit | 91.193 ms | -0.0707% | 30 (6.00%) - 8 high mild, 22 high severe |
Third round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 91.398 ms | +1.2693% | 28 (5.60%) - 8 high mild, 20 high severe |
| resolve_ws/rust-ws-inherit | 90.558 ms | +0.5349% | 26 (5.20%) - 8 high mild, 18 high severe |
Fourth round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/rust | 91.193 ms | +0.8302% | 26 (5.20%) - 11 high mild, 15 high severe |
| resolve_ws/rust-ws-inherit | 90.591 ms | +0.8267% | 34 (6.80%) - 6 high mild, 17 high severe |
I’ve tested this change several times using the resolve_ws/tikv benchmark suite.
My test env:
Model Name: MacBook Pro
Chip: Apple M4 Max
Total Number of Cores: 14 (10 performance and 4 efficiency)
Memory: 36 GB
Test result:
master commit: HEAD is now at c2c636a6d fix(toml): Remove workaround for rustc frontmatter support (#15570)
master: cargo bench -p benchsuite --bench resolve -- resolve_ws/tikv --save-baseline master --measurement-time 100 --sample-size 600
patch: cargo bench -p benchsuite --bench resolve -- resolve_ws/tikv --baseline master --measurement-time 100 --sample-size 600
First round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/tikv | 131.32 ms | -2.4203% | 42 (7.00%) - 18 high mild, 24 high severe |
Second round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/tikv | 133.14 ms | +0.8323% | 37 (6.17%) - 14 high mild, 23 high severe |
Third round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/tikv | 134.06 ms | +0.9986% | 30 (5.00%) - 10 high mild, 20 high severe |
Fourth round:
| Benchmark | Time (mean) | Change | Outliers |
|---|---|---|---|
| resolve_ws/tikv | 135.27 ms | +2.3135% | 106 (17.67%) - 71 high mild, 35 high severe |
Thanks for your review! 💚 💙 💜 💛 ❤️