-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Numerically intense algorithm runs slower in dart than javascript #7971
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
Comments
We need to inline floor, it occupies the top spot on the profile: 9.54% dart libm-2.15.so [.] floor I will look into it. Additional slow down might be coming from issue #5661 |
I enabled inlining of double.floor/double.ceil when SSE4.1 is available in r17278. This significantly increases performance of the computational core on my machine: roughly by a factor of 6. However we still don't inline them if SSE4.1 is not available (while V8 does have fallback paths for SSE2). We should consider adding similar ones. @unicomp21: what is your CPU? Added Fixed label. |
This comment was originally written by @unicomp21 X86 |
This comment was originally written by @unicomp21 Thanks! |
This comment was originally written by @unicomp21 btw, when will the fix show up in the m2 build? |
This comment was originally written by @unicomp21 Also, are there any plans for the compiler to vectorize to SSEx? Or perhaps adding something like Renderscript to the VM? |
This comment was originally written by @unicomp21 toInt appears to suffer from the same slowness, perhaps it needs to be inlined as well? |
This comment was originally written by @unicomp21 slow toInt sample, see |
Fast path of the toInt is inlined (convertion to a smi). However the result of toInt is not necessarily a smi or even mint, it can be big integer (beyond 64 bits). My suggestion would be to not use toInt at all in any numerically intense code for now. |
Actually on your benchmark toInt is always compiled down to DoubleToSmi instruction (optimistic assumption, if the value will not fit into a smi then code will cause a deopt). Resulting code seems to be fast. What are you comparing against? |
I see: RidgedMultifractal_Default reveals that Double.pow is not inlined. I have filed an Issue #8002 for that. |
This comment was originally written by @unicomp21
I'm still comparing to javascript, overall performance is still much slower. |
This issue was originally filed by @unicomp21
I've ported it to dart, and now it runs ~10x slower. The original javascript implementation is here
https://github.com/unicomp21/perlin-noise.js.git
while the dart port is here
https://github.com/unicomp21/RadTextures.git
From an algorithm perspective they should be identical. Don't know how I handle this one with a stop-watch timer. An instruction level profiler would be realy nice.
I'll take ya up on that help offer now ;) If this basis function (simplex perlin noise) can be made to run fast, there are a slew of other cool texturing functions that run on top of it. This is useful because large collections of mesh textures can be generated on the client rather than downloaded, cutting down on bandwidth by many orders of magnitude.
What steps will reproduce the problem?
2.
3.
What is the expected output? something fast
What do you see instead? something slooooow
What version of the product are you using? latest
On what operating system? linux, windows
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: