Comments (5)
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.
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.
__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.
@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.
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)
- Can you provide a browserify distribution? HOT 1
- How to limit the result count from the query? HOT 11
- how to search by id ? HOT 2
- tree.getById(id) how to get by id? HOT 2
- Why "RTree" is geographically even distribution while "RBush" is NOT? HOT 1
- About evenly geographic distribution when limit the result size HOT 2
- Invalid collision on maxX/Y (pixel-perfect collision false positive) HOT 3
- Does RBUSH supports to use Latitude and Longitude? HOT 5
- Hi i can't figure out how to use this library can anyone help? HOT 3
- Typescript attempts to use missing default constructor HOT 4
- How to search when usiong the extended class for points HOT 1
- is there any quick way to return the bounding box of tree itself? HOT 1
- Questions: Performance Remove + Moving item HOT 1
- Definition of "intersection" could be made more explicit in the readme HOT 2
- Returns all items when bounds provided to search contains center 0,0 HOT 3
- Support esm HOT 1
- search & collides support custom intersects & contains
- Balancing? HOT 1
- Unable to resolve dependency tree
- Performance benchmark vs other libraries HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rbush.