-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Make GlobalContext Sync #15967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make GlobalContext Sync #15967
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
Thanks! |
FYI we are fine with editing existing history and, in a case like this, I would prefer it over having fixup commits later in the history as it makes the commits I'm reviewing more understandable on their own. |
eb1396a
to
7f8e4f9
Compare
7f8e4f9
to
f2b8539
Compare
This will make it easier to change the implementation in the future.
64e7db5
to
cec5a22
Compare
a01b9bf
to
a590d3e
Compare
… is just a HashMap::defualt()
Previously, `gctx.shell().verbosity()` was used to check that `gctx.shell` is not borrowed. Since shell is now behind a `Mutex` and not a `RefCell`, this would hang waiting for the unlock instead panicking. Borrow state checking is now done using `Mutex::try_lock` in `GlobalContext::debug_assert_shell_not_borrowed`
a590d3e
to
9929c87
Compare
Thanks! |
Update cargo submodule 17 commits in 966f94733bbc94ca51ff9f1e4c49ad250ebbdc50..f2932725b045d361ff5f18ba02b1409dd1f44e71 2025-09-16 17:24:45 +0000 to 2025-09-24 11:31:26 +0000 - fix: use `host-tuple` for host target subsitution (rust-lang/cargo#16003) - test(build-std): move away from panic_immediate_abort (rust-lang/cargo#16006) - fix: Sparse URLs in `TomlLockfileSourceId` (rust-lang/cargo#15990) - refactor(gctx): extract toml dotted keys validation (rust-lang/cargo#15998) - feat: Add lint for global use of `hint-mostly-unused` (rust-lang/cargo#15995) - Make GlobalContext Sync (rust-lang/cargo#15967) - chore(deps): update cargo-semver-checks to v0.44.0 (rust-lang/cargo#15993) - fix(frontatter): Only allow horizontal whitespace after fences (rust-lang/cargo#15975) - docs: Add Lockfile schemas docs (rust-lang/cargo#15989) - Add parallel frontend to the build performance guide (rust-lang/cargo#15970) - chore(deps): update msrv (3 versions) to v1.88 (rust-lang/cargo#15988) - chore(deps): update msrv (1 version) to v1.90 (rust-lang/cargo#15984) - feat(cargo-util-schemas): Move lockfile schemas (rust-lang/cargo#15980) - Clarify multiple version requirement behavior (rust-lang/cargo#15979) - Adds ghostty as supported terminal for term integration (OSC 9;4) (rust-lang/cargo#15977) - docs(team): Fixed broken office hours link (rust-lang/cargo#15976) - docs: Clarify git sources vs git registries in source replacement documentation (rust-lang/cargo#15974) r? ghost
Update cargo submodule 17 commits in 966f94733bbc94ca51ff9f1e4c49ad250ebbdc50..f2932725b045d361ff5f18ba02b1409dd1f44e71 2025-09-16 17:24:45 +0000 to 2025-09-24 11:31:26 +0000 - fix: use `host-tuple` for host target subsitution (rust-lang/cargo#16003) - test(build-std): move away from panic_immediate_abort (rust-lang/cargo#16006) - fix: Sparse URLs in `TomlLockfileSourceId` (rust-lang/cargo#15990) - refactor(gctx): extract toml dotted keys validation (rust-lang/cargo#15998) - feat: Add lint for global use of `hint-mostly-unused` (rust-lang/cargo#15995) - Make GlobalContext Sync (rust-lang/cargo#15967) - chore(deps): update cargo-semver-checks to v0.44.0 (rust-lang/cargo#15993) - fix(frontatter): Only allow horizontal whitespace after fences (rust-lang/cargo#15975) - docs: Add Lockfile schemas docs (rust-lang/cargo#15989) - Add parallel frontend to the build performance guide (rust-lang/cargo#15970) - chore(deps): update msrv (3 versions) to v1.88 (rust-lang/cargo#15988) - chore(deps): update msrv (1 version) to v1.90 (rust-lang/cargo#15984) - feat(cargo-util-schemas): Move lockfile schemas (rust-lang/cargo#15980) - Clarify multiple version requirement behavior (rust-lang/cargo#15979) - Adds ghostty as supported terminal for term integration (OSC 9;4) (rust-lang/cargo#15977) - docs(team): Fixed broken office hours link (rust-lang/cargo#15976) - docs: Clarify git sources vs git registries in source replacement documentation (rust-lang/cargo#15974) r? ghost
Update cargo submodule 17 commits in 966f94733bbc94ca51ff9f1e4c49ad250ebbdc50..f2932725b045d361ff5f18ba02b1409dd1f44e71 2025-09-16 17:24:45 +0000 to 2025-09-24 11:31:26 +0000 - fix: use `host-tuple` for host target subsitution (rust-lang/cargo#16003) - test(build-std): move away from panic_immediate_abort (rust-lang/cargo#16006) - fix: Sparse URLs in `TomlLockfileSourceId` (rust-lang/cargo#15990) - refactor(gctx): extract toml dotted keys validation (rust-lang/cargo#15998) - feat: Add lint for global use of `hint-mostly-unused` (rust-lang/cargo#15995) - Make GlobalContext Sync (rust-lang/cargo#15967) - chore(deps): update cargo-semver-checks to v0.44.0 (rust-lang/cargo#15993) - fix(frontatter): Only allow horizontal whitespace after fences (rust-lang/cargo#15975) - docs: Add Lockfile schemas docs (rust-lang/cargo#15989) - Add parallel frontend to the build performance guide (rust-lang/cargo#15970) - chore(deps): update msrv (3 versions) to v1.88 (rust-lang/cargo#15988) - chore(deps): update msrv (1 version) to v1.90 (rust-lang/cargo#15984) - feat(cargo-util-schemas): Move lockfile schemas (rust-lang/cargo#15980) - Clarify multiple version requirement behavior (rust-lang/cargo#15979) - Adds ghostty as supported terminal for term integration (OSC 9;4) (rust-lang/cargo#15977) - docs(team): Fixed broken office hours link (rust-lang/cargo#15976) - docs: Clarify git sources vs git registries in source replacement documentation (rust-lang/cargo#15974) r? ghost
Update cargo submodule 17 commits in 966f94733bbc94ca51ff9f1e4c49ad250ebbdc50..f2932725b045d361ff5f18ba02b1409dd1f44e71 2025-09-16 17:24:45 +0000 to 2025-09-24 11:31:26 +0000 - fix: use `host-tuple` for host target subsitution (rust-lang/cargo#16003) - test(build-std): move away from panic_immediate_abort (rust-lang/cargo#16006) - fix: Sparse URLs in `TomlLockfileSourceId` (rust-lang/cargo#15990) - refactor(gctx): extract toml dotted keys validation (rust-lang/cargo#15998) - feat: Add lint for global use of `hint-mostly-unused` (rust-lang/cargo#15995) - Make GlobalContext Sync (rust-lang/cargo#15967) - chore(deps): update cargo-semver-checks to v0.44.0 (rust-lang/cargo#15993) - fix(frontatter): Only allow horizontal whitespace after fences (rust-lang/cargo#15975) - docs: Add Lockfile schemas docs (rust-lang/cargo#15989) - Add parallel frontend to the build performance guide (rust-lang/cargo#15970) - chore(deps): update msrv (3 versions) to v1.88 (rust-lang/cargo#15988) - chore(deps): update msrv (1 version) to v1.90 (rust-lang/cargo#15984) - feat(cargo-util-schemas): Move lockfile schemas (rust-lang/cargo#15980) - Clarify multiple version requirement behavior (rust-lang/cargo#15979) - Adds ghostty as supported terminal for term integration (OSC 9;4) (rust-lang/cargo#15977) - docs(team): Fixed broken office hours link (rust-lang/cargo#15976) - docs: Clarify git sources vs git registries in source replacement documentation (rust-lang/cargo#15974) r? ghost
Update cargo submodule 17 commits in 966f94733bbc94ca51ff9f1e4c49ad250ebbdc50..f2932725b045d361ff5f18ba02b1409dd1f44e71 2025-09-16 17:24:45 +0000 to 2025-09-24 11:31:26 +0000 - fix: use `host-tuple` for host target subsitution (rust-lang/cargo#16003) - test(build-std): move away from panic_immediate_abort (rust-lang/cargo#16006) - fix: Sparse URLs in `TomlLockfileSourceId` (rust-lang/cargo#15990) - refactor(gctx): extract toml dotted keys validation (rust-lang/cargo#15998) - feat: Add lint for global use of `hint-mostly-unused` (rust-lang/cargo#15995) - Make GlobalContext Sync (rust-lang/cargo#15967) - chore(deps): update cargo-semver-checks to v0.44.0 (rust-lang/cargo#15993) - fix(frontatter): Only allow horizontal whitespace after fences (rust-lang/cargo#15975) - docs: Add Lockfile schemas docs (rust-lang/cargo#15989) - Add parallel frontend to the build performance guide (rust-lang/cargo#15970) - chore(deps): update msrv (3 versions) to v1.88 (rust-lang/cargo#15988) - chore(deps): update msrv (1 version) to v1.90 (rust-lang/cargo#15984) - feat(cargo-util-schemas): Move lockfile schemas (rust-lang/cargo#15980) - Clarify multiple version requirement behavior (rust-lang/cargo#15979) - Adds ghostty as supported terminal for term integration (OSC 9;4) (rust-lang/cargo#15977) - docs(team): Fixed broken office hours link (rust-lang/cargo#15976) - docs: Clarify git sources vs git registries in source replacement documentation (rust-lang/cargo#15974) r? ghost
Update cargo submodule 17 commits in 966f94733bbc94ca51ff9f1e4c49ad250ebbdc50..f2932725b045d361ff5f18ba02b1409dd1f44e71 2025-09-16 17:24:45 +0000 to 2025-09-24 11:31:26 +0000 - fix: use `host-tuple` for host target subsitution (rust-lang/cargo#16003) - test(build-std): move away from panic_immediate_abort (rust-lang/cargo#16006) - fix: Sparse URLs in `TomlLockfileSourceId` (rust-lang/cargo#15990) - refactor(gctx): extract toml dotted keys validation (rust-lang/cargo#15998) - feat: Add lint for global use of `hint-mostly-unused` (rust-lang/cargo#15995) - Make GlobalContext Sync (rust-lang/cargo#15967) - chore(deps): update cargo-semver-checks to v0.44.0 (rust-lang/cargo#15993) - fix(frontatter): Only allow horizontal whitespace after fences (rust-lang/cargo#15975) - docs: Add Lockfile schemas docs (rust-lang/cargo#15989) - Add parallel frontend to the build performance guide (rust-lang/cargo#15970) - chore(deps): update msrv (3 versions) to v1.88 (rust-lang/cargo#15988) - chore(deps): update msrv (1 version) to v1.90 (rust-lang/cargo#15984) - feat(cargo-util-schemas): Move lockfile schemas (rust-lang/cargo#15980) - Clarify multiple version requirement behavior (rust-lang/cargo#15979) - Adds ghostty as supported terminal for term integration (OSC 9;4) (rust-lang/cargo#15977) - docs(team): Fixed broken office hours link (rust-lang/cargo#15976) - docs: Clarify git sources vs git registries in source replacement documentation (rust-lang/cargo#15974) r? ghost
What does this PR try to resolve?
By making
GlobalContext
Sync
, it will become much easier to parallelize parts of cargo. A concrete example is #15676.It was my understanding from #15934 (comment) that this would be a welcome change by the cargo team.
Overview
In
GlobalContext
and structs used in its fieldsRefCell
-s were replaced by either anstd::sync::Mutex
or anstd::sync::RwLock
, depending on API needsLazyCell
-s were replaced by a newOnceLock
implementation backed bystd::sync::OnceLock
, emulating unstable features needed by cargoLazyCell
/OnceLock
from fields where the initialization function is just aMutex<HashMap>::default()
util::context::tests::sync_context
test that does not compile ifGlobalContext
is notSync
How to test and review this PR?
This PR should add no user-facing changes. Tests must pass and benchmarks must report no changes.