Giter VIP home page Giter VIP logo

Comments (5)

mourner avatar mourner commented on August 27, 2024

I doubt that. Most of my experiments with WebAssembly have produced code that's slower than the JS implementation (if you optimize the latter well). I'll be happy for you to prove me wrong though — feel free to port. :)

from rbush.

darky avatar darky commented on August 27, 2024

I play with AssemblyScript and do successful port of this project: https://github.com/mourner/quickselect
Performance decrease of wasm version was ~4-5x ( ~120ms -> ~450ms ) via npm run bench
I investigate it and see that so many cost is __allocArray and __getArray ( ~0.25ms and ~0.13ms per call)
But call of wasm quickselect very cheap (0.004ms instead of 0.075ms of js version)
Maybe later transform from js to wasm will be cheaper.
Now, I think wasm win for long running stateful applications, when you can on startup initialise wasm side and do blazing fast calls of wasm functions from js :)

from rbush.

MaxGraey avatar MaxGraey commented on August 27, 2024

__getArray is slow becouse use reflection under the hood. Better use typed array (Float64Array for example) on AS side and __getFloat64Array on host side. Also with using unchecked like unchecked(arr[i] = x) and v = unchecked(arr[i]) for array's access you could speed up this more

from rbush.

darky avatar darky commented on August 27, 2024

@MaxGraey thanks, __getFloat64Array improve performance 2x (~0.05ms)
But it so slow yet on __getArray and __getFloat64Array .
I think need to wait https://github.com/WebAssembly/interface-types implementation in AssemblyScript and V8 engine.

from rbush.

MaxGraey avatar MaxGraey commented on August 27, 2024

Yes. interop cost in WebAssembly is weakest (slowest) part currently. So for best result better port whole or meaningful part of program instead just some hot but small paths

from rbush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.