-
-
Notifications
You must be signed in to change notification settings - Fork 763
refactor: optimize fuzzy matching with lazy initialization #2523
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
base: main
Are you sure you want to change the base?
Conversation
d5ee0fc to
f74e766
Compare
| ```yaml | ||
| # Global settings | ||
| verbose: true | ||
| disable-fuzzy: false |
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 just realized that, we are apparently inconsistency when it comes to _ vs - for word separation?
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 think the default is to use -, and we only use _ for experiments to mirror the environment variable. I’m open to discussing it, tho
| if !e.DisableFuzzy { | ||
| // Lazy initialization of fuzzy model | ||
| if e.fuzzyModel == nil { | ||
| e.setupFuzzyModel() | ||
| } | ||
| if e.fuzzyModel != nil { | ||
| didYouMean = e.fuzzyModel.SpellCheck(call.Task) | ||
| } |
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 should probably wrap this into a mutex.
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.
Good catch! I've implemented a Once to be sure this is executed only once
4371c38 to
b74a408
Compare
Problem
The fuzzy model was trained on every Task invocation (including shell autocompletion), causing performance issues with hundreds/thousands of tasks. The model is only needed when a task doesn't exist to show "Did you mean...?" suggestions.
Solution
Setup()) (thanks @trulede for the suggestion)--disable-fuzzyflag anddisable-fuzzytaskrc option to completely disable the featureChanges
Setup()to lazy init inGetTask()DisableFuzzyoption to taskrc, flags, and ExecutorPerformance
Compatibility
Fully backward compatible. Fuzzy matching enabled by default, users can opt-out via
.taskrc.ymlor--disable-fuzzy.Related Issues