scxtop: add search module with fuzzy matching #1971
Closed
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.
In order to enable filtering perf events in scxtop, we'll need fuzzy matching functionality. This module will provide the initial fuzzy search. At the moment, it's relatively naive but it will fuzzy match on missed characters and substrings (I'll probably add some manual levenshtein calculations as well to enable it to catch typos and out of order characters). Here are some current examples of what it will match on and what it won't:
Substring - "gettid" == "syscalls:sys_exit_gettid"
Missing - "ssall" == "syscalls:sys_exit_gettid"
Capitalization + substring + missing - "alrMcacEL" == "alarmtimer:alarmtimer_cancel"
Typo - "albrm" != "alarmtimer:alarmtimer_cancel"
The fuzzy matching is largely done using the fuzzy-matching crate, which is based on skim.
Here are some performance benchmarks, comparing fuzzy_search to a substring_search:
Given that the median is consistently less than 350 microseconds, we should be fine performance-wise. Benchmarking was done using Criterion.