help to improve vector_math via dart2js

41 views
Skip to first unread message

David Bernard

unread,
Jul 26, 2013, 5:16:47 AM7/26/13
to dartga...@googlegroups.com
Hi,

I try to create a game in dart, but I want to run it on chrome, firefox so the code is converted into js (via dart2js). I use a lot vector_math (pseudo physic, collisions, ...) But the js generated by dart2js for vector_math is full of "useless code" : range check, use of $index instead of [ ] native operator, ...

Result :
 ~ 1 fps for code generated by dart2js on Firefox (on a sample application)
~ 10 fps for same code but where I manually replace the js code of Vector3.setFrom, Vector3.add, Vector3.sub
Does someone has a better idea to improve the current state (other than open issue and wait) ?

Cheers,

/davidB

all the code is available (on github : glf, dartemis_toolbox, vdrones)

Bernhard Pichler

unread,
Jul 27, 2013, 6:52:38 AM7/27/13
to dartga...@googlegroups.com
Hi,

I think the vector_math library is using the Float32x4 SIMD instructions of Dart, right? Since the support of the SIMD instructions in dart2js is pretty new, i did some tests and the performance is not great at all. As you said the JavaScript code contains a lot of bounds checks and also checks for the "number" type. I also tried to remove all this useless code in JavaScript by hand - in fact i optimized the Float32x4 class in JavaScript by hand and the performance was still very slow. I'm sure John McCutchan is aware of this problem and he (or the dart2js team) will find a solution to make the code run faster. If this can't be solved the SIMD instructions shouldn't be used if you have to compile to JavaScript.

Bernhard
Reply all
Reply to author
Forward
0 new messages