Repository navigation
fix(syntax): keep pack loads off the grammar store lock - #62
Merged
Merged
Conversation
Every lookup held the store's state lock while it resolved a tag, which covers hashing a pack's files, opening its library and compiling its queries. The diff view asks the store for a language's status on the UI thread when a highlight lands, so a frame could wait for a different language's pack to load on the worker. If the fetch thread failed to spawn, queuing re-locked the state that lookup still held. Resolving now runs under a lock of its own and touches the state lock only for map updates, so resolved tags answer at once while one tag still loads once. The diff view reads the resolved status without resolving, the catalog checks installed files outside the lock, and a failed fetch-thread spawn is reported to the caller, which records the tag as unavailable.
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.
A frame could stall while the highlight worker loaded an unrelated grammar pack, because every store lookup held the store's lock across hashing, opening and compiling a pack, and the diff view asks the store for a language's status on the UI thread. Resolving now has its own lock and touches the state lock only for map updates, the diff view uses a new non-resolving
GrammarStore::resolvedread, the catalog checks installed files outside the lock, and a failed fetch-thread spawn marks the tag unavailable instead of re-locking the state its caller held.