Commit 5561737
committed
Auto merge of #14211 - Eh2406:default-without-lock, r=epage
dont make new constant InternedString in hot path
### What does this PR try to resolve?
`InternedString::new` always takes a `Mutex` lock. This is not a big deal because `new` is usually only called as external io is done (i.e not in a hot loop) and cargo is single threaded so the lock is not contested. However, dealing with the "default" feature happens deep within the resolver (i.e in a hot loop). So we may as well remove this overhead. I can get runtime benchmarks if that is desired.
For context: My pubgrub work would very much like to run cargoes resolver simultaneously in multiple threads. This `Mutex` is a major obstacle for that effort.
### How should we test and review this PR?
Internal re-factor and test still pass.
Also confirmed the semantics of `static` in https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Const.20evaluation.20and.20equality
### Additional information
There are other constant InternedString's in `src/cargo/core/profiles.rs`. I don't think they are in a hot enough path to justify more `static`s. But I will change if requested.File tree
4 files changed
+25
-15
lines changed- src/cargo
- core/resolver
- ops/tree
- util
4 files changed
+25
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
748 | | - | |
749 | | - | |
750 | | - | |
| 748 | + | |
| 749 | + | |
751 | 750 | | |
752 | 751 | | |
753 | 752 | | |
| |||
762 | 761 | | |
763 | 762 | | |
764 | 763 | | |
765 | | - | |
766 | | - | |
767 | | - | |
| 764 | + | |
| 765 | + | |
768 | 766 | | |
769 | 767 | | |
770 | 768 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
| 418 | + | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
| 508 | + | |
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
17 | 29 | | |
18 | 30 | | |
19 | 31 | | |
| |||
60 | 72 | | |
61 | 73 | | |
62 | 74 | | |
63 | | - | |
64 | | - | |
| 75 | + | |
| 76 | + | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| |||
0 commit comments