Repository navigation
docs(repository): list the worktree-registry lock among the process-level singletons - #3961
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
# Cachingspec insrc/git/repository/mod.rsenumerates every process-global singleton the module reasons about, split into two lists: caches under "Two layers, two scopes", and non-cacheOnceLock/LazyLocksingletons under "Other process-level singletons".WORKTREE_REGISTRY_LOCKS, added in #3954, is in neither — it lives in this file but holds locks rather than git data, so it fell between the cache list (which only covers in-file caches) and the singleton list (whose examples are all in other modules). This adds it to the singleton list, naming what it is keyed by and pointing at the static's own doc comment for the ordering rules.Docs only — no behavior change, so no regression test.
cargo check --libpasses; the diff is five//!lines.Why it belongs in the singleton list rather than the cache list
The singleton list is prefaced "process-global singletons that are lazy initialization, not caches — the container is initialized once and never replaced, with no underlying external state that could go stale".
WORKTREE_REGISTRY_LOCKSfits exactly: theDashMapis created once, each entry is anArc<RwLock<()>>handed to everyRepositoryresolving to that canonical common dir (mod.rs), and nothing it stores can go stale because it stores no git state.