Shared publicly  - 
Finally got around to running new Box2D performance numbers. This time I concentrate more on VMs than compilers, and things have changed rather a lot over the past year or so. I also cover AS3, asm.js, and Dart.
Ray Cromwell's profile photoToby Reyelts's profile photoJoel Webber's profile photoVyacheslav Egorov's profile photo
Does "asm.js (Firefox Nightly)" use the same as code that is measured at "Emscripten (Chrome)"?
+Vyacheslav Egorov It does. (in the /c dir) runs the Emscripten compile with ASM_JS=1, and I ran the output through both V8 (via Chrome) and OdinMonkey (via the Firefox nightly).
+Joel Webber I'd call them the same just to make it obvious then :-)

Thanks for measuring this stuff again. I should look why Dart performs so poorly, it should at least be at Box2DWeb level or faster.
I guess that was a bit unclear -- I was deep enough in the weeds fiddling with the makefiles and such that my brain just conflated asm.js and emscripten entirely...

I wondered about the Dart performance as well. I've been chatting with +Dominic Hamon and +John McCutchan on getting the code working and up-to-date. But it may well be that I screwed something up, so please let me know if so!

(Edit: And +Jon Kirkman, who actually updated the code for me.)
+Stefan Haustein As bizarre as it sounds, that should be a lot more feasible with Russ's new calling convention (didn't someone already get NaCl going?). If they could get iOS binaries sorted out as well (without rooting), I'd love to play around with writing games in Go.
+Joel Webber +Vyacheslav Egorov The current box2d port is using object properties to store double values instead of typed data arrays. +Dominic Hamon is almost done updating so that it uses typed data arrays. Very interested in the performance after that change.
The smiley wasn't meant as an indicator for this being a joke -- I am positively looking forward to actually doing this.... :)
+John McCutchan I expect that'll make a big difference. I'll happily run another update as soon as that's ready to go.
+John McCutchan does Box2DWeb use typed data arrays in JavaScript? If it does not than this is not what is causing the difference.
+Vyacheslav Egorov Doesn't look like it. The Box2D vector/matrix objects (e.g., b2Vec2) appear to be just simple objects with properties, rather than anything array-like.
+Joel Webber +John McCutchan  yep. 

whatever is causing a difference is worth investigating. (the top of the profile according to Srdjan Mitrovic is all GC internals).

One thing that is definitely worth fixing in the Box2D.dart is usage of num annotation on double fields (and storing a mixture of doubles/integers in those fields). All fields should be marked double and should not contain integers ever :-)
+Dominic Hamon Are you going to follow suite and require box2d to use doubles everywhere? The VM now (will soon? +Vyacheslav Egorov) optimizes based on types stored into object fields, if these are not stable deoptimizations can occur.
Thanks -- makes me feel slightly better that I'm not submitting them all myself :)
Thanks, thought there were two now (could have figured out by the user name...)
+Joel Webber I imagine Go would have a little trouble with asm.js because asm.js doesn't support GC. While you could implement GC to "mark and sweep" the fake asm.js heap, you can't really, AFAIK, inspect the stack. Everytime you go to alloc a Go object, you wouldn't be able to inspect the stack, unless the asm.js explicitly emitted explicit stack manipulation code, which would likely slow down stuff.

Would be interesting to hack the GWT version to use TypedArrays and asm.js style coercions.
+Vyacheslav Egorov It's the standard Mac download, which appears to be 64-bit: (Wed Apr 17 15:55:16 2013)
Ugh. The Hacker News community has really gone downhill. 
+Matt Mastracci reading some of the hacker news and reddit comments really makes your point.

TIL that if your website works fine on modern mobile browsers, but has a slight rendering issue on the old-and-out-of-date android browser, you unleash snarky douche-bags.

+Joel Webber You are a more patient man than me :).
+Vyacheslav Egorov Just gave it a shot, and it's a bit faster -- 36.32ms +/- 8. So the variance is a bit high, but it's in the same ballpark as box2dweb on Firefox.

I suspect the SIMD stuff will make a significant difference, and I look forward to trying it.
+Matt Mastracci +Jaime Yap Yeah... I knew the tools/trolls would be there as always, but I was a bit surprised at just how much vitriol I got for messing up the site a bit on mobile -- I mean for fsck's sake, it's a random blog thrown together by someone with no design sense. Then there was the guy who wrote several paragraphs of anger about the fact that I referred to C++ as C (!).

And of course about 18 different people were incensed (incensed I say!) that I used the old-ass version of gcc that was sitting on my mac. Dear god, what's wrong with you man! 5-year-old software? Are you a fool?! Never mind that I got worse results from both Clang and gcc 4.8. Fucktards.
+Joel Webber yeah, so it is really 10% as anticipated. thanks for measuring.   

we actually have a GC fix in the pipeline that is expected to make quite a noticable difference without modifications to Box2D itself. I'll ping you once that lands :-)
+Joel Webber I think MG Sielger may be right that comment systems are a waste of time, given the number of people who intentionally are drive-by-assholes.

I love the comments in the AppStores, the sense of entitlement is epic. Louis CK where are you?
I ran w/e you had on github at head through the profiler again, and it was telling me that 40% of the time was spent in StrictMath cos and sin. Did I miss the part where I had to set some flag or something to make it use lookup tables or w/e?
+Toby Reyelts Hmm... I seem to recall fiddling with using trig tables when I first ran these benchmarks a year or so ago, but I don't recall it making much of a difference (though of course that memory could be off).

It might be a little unfair to have the Java implementation skip the standard trig functions, though, given that the other implementations don't do this.
Go back and read your older post for a refresher. You said you flipped some flag on in box2d, but at least in the version I'm running, it's still spending 40% of its time in StrictMath.cos/sin.
+Toby Reyelts Whoops, I see it now. IIRC that "flag" was just a boolean buried in the jBox2D code. I'm using exactly the same version as last time, which I believe has that flag flipped, but I'll need to dig into the jar to check again. Will do so after the rugrat's in bed tonight.
Yeah, I actually discovered this while fooling around some. The box2d version you have in github doesn't have it enabled. I downloaded a version that did have it enabled, but then I had to change some code in your main harness (box2d API changes), and the profile changed drastically. I didn't get around to just patching the version you have in github.
+Vyacheslav Egorov Thanks, I've been meaning to come back and update the metrics and graphs on several fronts, so I'll definitely do so with the new VM. Probably tonight, after I get the rugrat to bed.
+Joel Webber V8 also just enabled some optimizations that should affect Box2D version that uses normal objects (vs. Box2D that uses Emscripten) by eliminating repetitive boxing of fields. 
Add a comment...