perf: replace fastest-levenshtein with optimized-fastest-levenshtein (Rust, 6–9× faster on string comparison)#43855
Conversation
…(Rust, 6–9× faster)
|
👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions:
You'll need to revert all of the files you changed that match that list using GitHub Desktop or The complete list of files we can't accept are:
We also can't accept contributions to files in the content directory with frontmatter |
How to review these changes 👓Thank you for your contribution. To review these changes, choose one of the following options: A Hubber will need to deploy your changes internally to review. Table of review linksNote: Please update the URL for your staging server or codespace. This pull request contains code changes, so we will not generate a table of review links. 🤖 This comment is automatically generated. |
|
What this does
Replaces
fastest-levenshteinwithoptimized-fastest-levenshtein— a full drop-in replacement implemented in Rust via N-API.The import is updated to use the aliased
distance/closestexports so zero call-site changes are needed elsewhere.Benchmark results (Apple M2, Node.js v25.2.1, mitata)
fastest-levenshtein(JS)optimized-fastest-levenshtein(Rust)The algorithm complexity drops from O(n × m) to O(n × ⌈m/64⌉) — processing 64 DP columns per CPU instruction using bitwise arithmetic. The benefit grows with string length.
Why it's safe
fast-levenshtein(same underlying Myers algorithm)get(a,b),distance(a,b)(alias), andclosest(str, arr)— completefastest-levenshteinAPI paritySource: https://github.com/dev-kjma/faster-levenshtein · https://www.npmjs.com/package/optimized-fastest-levenshtein