-
Notifications
You must be signed in to change notification settings - Fork 11
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
Stop cloning the index state #200
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloning attr-stack and attr-matches per path isn't the intended use - these need to be mutable. Creating a thread-local repo per path also isn't intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I was just expecting a 😆 emoji.
I probably didn't interpret your code correctly. This was adapted from this line:
gengo/gengo/src/lib.rs
Line 140 in 14fb5c3
A
GitState
, which hasattr_stack
andattr_matches
fields, gets cloned here to attain a mutable reference (or so I thought). I thought this closure would do exactly that: return a thread-local repo and state clone per entry, which is effectively per-path for our uses.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could be doing that, that's true. But what I see here still happily clones two structures in order to make them mutable. Also,
repo.to_thread_local()
is called once per path.The problem is that the whole
self
seems to be tuned to beSync
and thus is read-only on top of that. The one coordinating the parallelism is responsible for passing in mutable state. I get it, each implementation has its own state, but if that's the case it must be a type parameter somewhere so it can be instantiated and passed in mutably.Maybe this happened due to
rayon
which clearly prefersSync
(share immutable state or shared mutable state behind locks), but even withrayon
there are ways to get thread-local state that I strongly recommend getting into this method call.This really is all I can say here, so: Happy Rusting :)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, thanks again! I do have a habit of avoiding mutable references in favor of immutable references, which influenced my design decisions here. Thanks for the insight!