Skip to content

Conversation

@vmaerten
Copy link
Member

@vmaerten vmaerten commented Nov 20, 2025

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

  • Lazy initialization: Train fuzzy model only when a task is not found (not during Setup()) (thanks @trulede for the suggestion)
  • New option: --disable-fuzzy flag and disable-fuzzy taskrc option to completely disable the feature

Changes

  • Moved fuzzy model training from Setup() to lazy init in GetTask()
  • Added DisableFuzzy option to taskrc, flags, and Executor
  • Updated shell completions (zsh, fish, powershell)
  • Added documentation for new option

Performance

  • Before: Fuzzy model trained every time, even for autocompletion
  • After: Zero overhead for normal operations, training only on task-not-found errors

Compatibility

Fully backward compatible. Fuzzy matching enabled by default, users can opt-out via .taskrc.yml or --disable-fuzzy.

Related Issues

@vmaerten vmaerten changed the title fix: disable fuzzy refactor: optimize fuzzy matching with lazy initialization Nov 23, 2025
@vmaerten vmaerten marked this pull request as ready for review November 23, 2025 21:00
```yaml
# Global settings
verbose: true
disable-fuzzy: false
Copy link
Member

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?

Copy link
Member Author

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

Comment on lines 453 to 457
if !e.DisableFuzzy {
// Lazy initialization of fuzzy model
if e.fuzzyModel == nil {
e.setupFuzzyModel()
}
if e.fuzzyModel != nil {
didYouMean = e.fuzzyModel.SpellCheck(call.Task)
}
Copy link
Member

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.

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants