jeancroy / FuzzySearch

:mag: Fast autocomplete suggestion engine using approximate string matching
MIT License
194 stars 32 forks source link

Performance #13

Closed FrogTheFrog closed 6 years ago

FrogTheFrog commented 6 years ago

Hello,

I was planing on rewriting fuzz-aldrin-plus to c++, until I found this library. It seems to be more suited for my case, however what matters to me is performance. Is it more or less like in fuzz-aldrin-plus? I would test performance myself, but I'm unable to do it for a couple of days (and I can't get this question out of my head).

jeancroy commented 6 years ago

I'll say this about performances.

fuzz-aldrin-plus is has a relatively expensive score function. But it has a very strict rule to what is a match, and a very fast way to prune non match.

fuzz-aldrin-plus is designed around the programmer text editor use case and had some good success in that niche.


FuzzySearch: Each match is computed way faster, in fact the a word scoring is just slightly slower than the fast pruning step of fuzz-aldrin-plus. In return we do compute the score for everything, also we do extra work to handle multi-words, out of order words.

FuzzySearch use bit parallel operations to speed thing up, which seems always popular with the performance / c crowd. I use a dictionary to store / query the bit maps, but if you know you have a small alphabet (ascii) an array will be faster. You'll see at some place I limit myself to 30 bits, and that is basically because I do not have a uint type in javascript.

It is based on relatively "recent" research paper which personally I like.


Speed, it's a good question. And the answer may be it depend. Things like % of entry that is considered a match in fuzz-aldrin-plus. Complex multi word query in FuzzySearch. Usually I setup larger benchmark using FuzzySearch while still feeling "interactive"

Speaking of which, in a search-as-you type scenario, the biggest speed gain I haven't implemented is to cancel previous search and start next one right away.


Hope this help :) I'll be happy to link to other implementations on my doc page

FrogTheFrog commented 6 years ago

Thanks for the info! :)