Skip to content

dont make new constant InternedString in hot path #14211

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

Eh2406
Copy link
Contributor

@Eh2406 Eh2406 commented Jul 8, 2024

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 statics. But I will change if requested.

@rustbot
Copy link
Collaborator

rustbot commented Jul 8, 2024

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

@rustbot rustbot added A-dependency-resolution Area: dependency resolution and the resolver A-features2 Area: issues specifically related to the v2 feature resolver Command-tree S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2024
@Eh2406 Eh2406 force-pushed the default-without-lock branch from c8070a1 to 106c86a Compare July 8, 2024 21:46
@epage
Copy link
Contributor

epage commented Jul 8, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Jul 8, 2024

📌 Commit 106c86a has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2024
@bors
Copy link
Contributor

bors commented Jul 8, 2024

⌛ Testing commit 106c86a with merge 5561737...

@bors
Copy link
Contributor

bors commented Jul 8, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing 5561737 to master...

@bors bors merged commit 5561737 into rust-lang:master Jul 8, 2024
14 of 22 checks passed
@Eh2406 Eh2406 deleted the default-without-lock branch July 9, 2024 16:43
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2024
Update cargo

31 commits in 154fdac39ae9629954e19e9986fd2cf2cdd8d964..a2b58c3dad4d554ba01ed6c45c41ff85390560f2
2024-07-07 01:28:23 +0000 to 2024-07-16 00:52:02 +0000
- chore(ci): bump CI tools (rust-lang/cargo#14257)
- test: migrate fetch and list_availables to snapbox (rust-lang/cargo#14214)
- chore: downgrade to jobserver@0.1.28 (rust-lang/cargo#14254)
- perf(source): Don't `du` on every git source load (rust-lang/cargo#14252)
- fix(source): Don't warn about unreferenced duplicate packages (rust-lang/cargo#14239)
- feat(test): Add cargo_test to test-support prelude (rust-lang/cargo#14243)
- Add workflow to publish Cargo automatically (rust-lang/cargo#14202)
- test: migrate implicit_features to snapbox (rust-lang/cargo#14245)
- test: migrate build-std/main to snapbox (rust-lang/cargo#14241)
- test: migrate check_cfg to snapbox (rust-lang/cargo#14235)
- refactor(source): More RecursivePathSource clean up (rust-lang/cargo#14231)
- Add more profiling traces (rust-lang/cargo#14238)
- fix(overrides): Don't warn on duplicate packages from using '..' (rust-lang/cargo#14234)
- fix(test): Redact elapsed time in the minutes time frame (rust-lang/cargo#14233)
- test: Migrate lto tests to snapbox (rust-lang/cargo#14209)
- fix: Ensure dep/feature activates the dependency on 2024 (rust-lang/cargo#14221)
- chore(docs): update index of reference (rust-lang/cargo#14228)
- test: migrate test to snapbox (rust-lang/cargo#14226)
- chore: remove duplicate words (rust-lang/cargo#14229)
- docs(contrib): Document things I look for in RFCs (rust-lang/cargo#14222)
- docs(ref): Note MSRV for features in the docs (rust-lang/cargo#14224)
- test(progress): Resolve flakiness (rust-lang/cargo#14223)
- fix(test): Reduce over-prescription to the caller (rust-lang/cargo#14217)
- refactor: move get_source_id out of registry (rust-lang/cargo#14218)
- fix: rename to `rustdoc::broken_intra_doc_links` (rust-lang/cargo#14215)
- test: migrate member_errors, multitarget and new to snapbox (rust-lang/cargo#14210)
- test: migrate generate_lockfile and glob_targets to snapbox (rust-lang/cargo#14200)
- test: Ensure --list test works with cargo-bloat (rust-lang/cargo#14213)
- dont make new constant InternedString in hot path (rust-lang/cargo#14211)
- Fix compatible_with_older_cargo test. (rust-lang/cargo#14212)
- test: migrate metabuild, metadata and net_config to snapbox (rust-lang/cargo#14162)
@rustbot rustbot added this to the 1.81.0 milestone Jul 17, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver A-features2 Area: issues specifically related to the v2 feature resolver Command-tree S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants