-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Faster startup by offloading glob matcher building to a worker thread #2868
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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.
I've had problems in the past with threads that are never joined. Are we sure this can not cause any problems?
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.
I gave this some thought, but in the end couldn't see any possible failure mode. The thread is so simple that it's trivial to reason about its exact behaviour.
I believe it's okay to forgo joining the thread because there's no resource the thread holds that needs to be released upon halting -
BUILTIN_MAPPINGS
is'static
, and the halt flag is safely behind anArc
. The only synchronization requirement is to make sure that it indeed does halt, which it obviously does.If you prefer defensive coding just to be safe, I can do that too. But in this case I really don't think it's necessary.
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.
We recently had a problem in another project of mine where a non-joined thread caused problems on Windows (sharkdp/numbat#298). But that might have been only due to the fact that the background thread was accessing the network(?).
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.
Anyway, I guess I'm okay with giving this a shot 😄. But those type of things can be hard to track down (spurious crashes that depend on precise timings).
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.
Yeah in that case releasing the socket (a shared resource) would require synchronization. We don't have that problem here.
I guess I'll add a comment in the threading code to remind future maintainers to watch out for synchronization issues if it ever starts to hold interesting resources in the future.
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.
Also, that's a really interesting project you've got there! When I've got time I would like to take a look at the possibility of integrating it with Krunner.
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.
Great idea. Let me know how if you have problems with the current API. It's not really stable and/or particularly nice at the moment, but I have built several frontends for Numbat so far. And there is a 3rd party integration into a krunner-like launcher here: https://github.com/MatthiasGrandl/Loungy/blob/main/src/commands/root/numbat.rs