Skip to content

scxtop: add search module with fuzzy matching #1971

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

Closed

Conversation

yaakov-stein
Copy link
Collaborator

@yaakov-stein yaakov-stein commented May 23, 2025

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:

Screenshot 2025-05-23 at 5 53 13 PM

Given that the median is consistently less than 350 microseconds, we should be fine performance-wise. Benchmarking was done using Criterion.

@hodgesds hodgesds requested review from JakeHillion and etsal May 23, 2025 23:17
@yaakov-stein
Copy link
Collaborator Author

Going to update with a new fuzzy matcher, will post a new PR next week.

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.

1 participant