-
Notifications
You must be signed in to change notification settings - Fork 128
Use fuzzy-native as an alternate scoring system
#374
Conversation
The old useAlternateScoring config option has been renamed to scoringSystem and has been converted to an enum, to accommodate the future native-fuzzy system.
| return items | ||
| } | ||
|
|
||
| return this.nativeFuzzy.match(query, {maxResults: MAX_RESULTS}).map( |
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.
For now, we're executing native-fuzzy on a single thread, but we can easily change this in the future
| return {uri: filePath, filePath, label} | ||
| } | ||
|
|
||
| getAbsolutePath (relativePath) { |
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.
This method is not great because it'll do a few fs accesses via fs.existSync, but it should not be very expensive because it does it against the list of filtered items (which is maximum 10 items).
This means that it'll do 10 * number of opened projects file system accesses. Since I don't expect users having many projects opened in the same window, this should be fine
spec/fuzzy-finder-spec.js
Outdated
| [false, 'standard'], | ||
| [true, 'standard'], | ||
| [false, 'alternate'] | ||
| [false, 'fast'] |
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 don't think it's worth to test on every single permutation of useRipGrep:scoringSystem, since these two params are orthogonal, so I've just selected a few permutations that ensure that both variables get fully tested.
|
uhm, |
|
Ok, I've been able to build and use
I think that both issues are related with the fact that the package is not prepared for electron v2.0. I'm not sure if this is related to the issue that's happening on AppVeyor (I don't think so). |
This is expected; EDIT: Oh, and the |
|
Try adding |
Oh interesting, I still have to learn a lot about Atom 😅
I'm gonna try, thanks! |
|
Ok, that fixed the issue 😄 Now the remaining issue is the one caused by these lines: https://github.com/hansonw/fuzzy-native/blob/master/lib/main.js#L10-L11 |
|
Ok, using a fork that adds support for electron v2 we're able to run the tests (only that 2 of them fail 😅), I'm gonna try to reproduce the failures on my windows machine (on OSX all of them pass) We're making progress! |
|
Yay! AppVeyor builds are finally passing 😄 There was a test that didn't contain correct Windows paths and it didn't work well with the path transformations that the logic for |
|
For some reason Travis builds get queued forever: https://travis-ci.org/atom/fuzzy-finder/builds/512728958?utm_source=github_status&utm_medium=notification ... I'll check back tomorrow |
maxbrunsfeld
left a comment
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.
This looks so great! Can't wait to try it out on a large project.
package.json
Outdated
| "fs-plus": "^3.0.0", | ||
| "fuzzaldrin": "^2.0", | ||
| "fuzzaldrin-plus": "^0.6.0", | ||
| "fuzzy-native": "git://github.com/rafeca/fuzzy-native.git#electron-v2", |
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.
Maybe you should publish this to NPM as @atom/fuzzy-native or something. That's what we've done for a few forks that we've had in the past, like nsfw and react.
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.
Sounds good, I'll do that
|
I've forked It seems that I'll also set up a similar CI system that the original |
|
Ok, after a few retries all tests passing, I'm proceeding to merge this PR 🙏 |
Description of the Change
This PR does two things:
useAlternateScoringconfig option to convert it to an enum calledscoringSystems(using the same default value as before).scoringSystemcalledfast(🤷♂️) which usesfuzzy-nativeto dramatically improve filtering times on large projects.Alternate Designs
A few other options have been considered:
nuclide-prebuilt-libspackage instead offuzzy-native.fuzzy-nativefiltering logic executed in a background thread.At the end, this solution is what IMHO gives more benefits and less tradeoffs per unit of effort 😅
For more information about benefits/tradeoffs, check out the discussion on the applicable issue.
Benefits
Drastically faster filtering for large projects, which are now usable.
native-fuzzyFor the benchmark I've configured
native-fuzzyto use a single thread. When using 4 threads the time to filter improves by ~2-3X on large projects but stays almost the same for medium/small.Possible Drawbacks
Yet a new scoring system added. As a follow-up we may decided to remove the
standardscoring system, which was superseeded by thealternateone 3 years ago.Applicable Issues
#370