-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improve ported implementation #10
Comments
It still uses arrays, though fast-levenshtein re-uses them: Also the benchmarks show it's slower:
|
I have finished my benchmarking PR, #2, which adds the benchmarks to the Azure Pipelines, and while everything does work, we are missing the function that allows us to remove the allocated strings from memory.. Due to that, we cannot benchmark this "properly" yet. The stacktrace for the error is as follows:
If it's an error in the current code, please let us know or leave a PR, I'm sure @kyranet wouldn't mind! After this is fixed (and no other errors creep up), we can give this a proper benchmark. 👍 |
Yeah, it seems @vladfrangu This strange. But I recommend use |
Uhm, not a fan of multiple memory allocations, that approach is very complex and could be documented more. But I'm up to porting it if it's the fastest approach, I didn't know about that one! Also I think the memory issue @vladfrangu is reporting is related to this: Line 13 in 90d54df
As it's creating new strings into the Wasm memory, but never freeing them, unless I'm missing something 😅 |
By the way, does AssemblyScript give any mechanism to create a value array (without pointers to memory)? I think dropping memory allocation, deallocation, and accesses, would allow further optimizations, speeding up operations substantially. |
Yes, if you alloc new string on js side you should free it. @kyranet You could work with raw linear memory directly. Like in game-of-life example |
That's what I want to do, the new docs show uses of var str = myModule.__retain(myModule.__allocString("my string"));
var foo = new myModule.Foo(str);
// do something with foo
myModule.__release(foo);
myModule.__release(str); But those are for the
Checked it, it uses |
You can't avoid this especially when working with strings. Wasm hasn't shadow stack, only locals & globals and linear memory (heap) |
@vladfrangu's benchmark PR got merged! The reports from Azure Pipelines: Benchmark Results$ node benchmark/benchmark Running Word levenshtein-wasm x 473 ops/sec ±1.01% (86 runs sampled) js-levenshtein x 2,176 ops/sec ±0.92% (89 runs sampled) talisman x 1,846 ops/sec ±1.00% (91 runs sampled) levenshtein-edit-distance x 1,567 ops/sec ±1.23% (89 runs sampled) leven x 1,532 ops/sec ±1.10% (89 runs sampled) fast-levenshtein x 1,307 ops/sec ±1.02% (89 runs sampled) Fastest is js-levenshtein Running paragraph levenshtein-wasm x 21.20 ops/sec ±1.56% (39 runs sampled) js-levenshtein x 104 ops/sec ±0.96% (74 runs sampled) talisman x 68.87 ops/sec ±1.07% (69 runs sampled) levenshtein-edit-distance x 59.59 ops/sec ±1.24% (61 runs sampled) leven x 60.67 ops/sec ±0.86% (62 runs sampled) fast-levenshtein x 41.88 ops/sec ±1.67% (55 runs sampled) Fastest is js-levenshtein Running Sentence levenshtein-wasm x 435 ops/sec ±0.85% (89 runs sampled) js-levenshtein x 1,932 ops/sec ±1.01% (91 runs sampled) talisman x 1,445 ops/sec ±0.79% (92 runs sampled) levenshtein-edit-distance x 1,139 ops/sec ±1.20% (88 runs sampled) leven x 1,157 ops/sec ±1.07% (90 runs sampled) fast-levenshtein x 856 ops/sec ±1.12% (87 runs sampled) Fastest is js-levenshtein Done in 116.09s. The newest master has the latest code from AssemblyScript, I also noticed the output code grew up a lot (from around ~450 lines to ~2600 lines), however, this Lines 14 to 21 in 9cfdac7
I will port |
Update: I have ported Benchmark ResultsRunning Word levenshtein-wasm x 623 ops/sec ±0.73% (92 runs sampled) js-levenshtein x 1,815 ops/sec ±0.41% (93 runs sampled) talisman x 1,666 ops/sec ±1.66% (90 runs sampled) levenshtein-edit-distance x 1,441 ops/sec ±0.67% (88 runs sampled) leven x 1,483 ops/sec ±0.63% (91 runs sampled) fast-levenshtein x 1,055 ops/sec ±2.23% (83 runs sampled) Fastest is js-levenshtein Running paragraph levenshtein-wasm x 34.44 ops/sec ±1.26% (59 runs sampled) js-levenshtein x 72.18 ops/sec ±0.41% (72 runs sampled) talisman x 56.72 ops/sec ±1.41% (60 runs sampled) levenshtein-edit-distance x 55.15 ops/sec ±1.32% (70 runs sampled) leven x 57.97 ops/sec ±0.33% (73 runs sampled) fast-levenshtein x 35.40 ops/sec ±0.32% (61 runs sampled) Fastest is js-levenshtein Running Sentence levenshtein-wasm x 779 ops/sec ±0.34% (93 runs sampled) js-levenshtein x 1,630 ops/sec ±0.18% (95 runs sampled) talisman x 1,274 ops/sec ±0.27% (95 runs sampled) levenshtein-edit-distance x 1,141 ops/sec ±0.54% (94 runs sampled) leven x 1,175 ops/sec ±0.27% (95 runs sampled) fast-levenshtein x 726 ops/sec ±0.22% (93 runs sampled) Fastest is js-levenshtein Done in 120.07s. I have just released In PackagePhobia, the bundle size has grown from 77.0kB to 514kB, and the code performs greatly worse (from being almost as fast as |
I guess this wasm version is port of levenshtein-js. Wdyt about port fast-levenshtein instead? It looks like much simpler and faster and don't require store full matrix.
The text was updated successfully, but these errors were encountered: