baldrick icon indicating copy to clipboard operation
baldrick copied to clipboard

Performance improvements

Open saem opened this issue 5 years ago • 0 comments

Just to let you know I took a quick look at your ECS, it's pretty cool! There might be some wick performance wins that you might be interested in.

I forked the repo and made some quick changes, mostly the default map implementation in Haxe is not great for performance. It can easily lead to V8 permanently deoptimizing any object you put in it.

So in my own playing around I hacked together a wrapper for the default JavaScript map implemention and bright that over from another project. You can check it out in my fork here: https://github.com/saem/baldrick. I made a few other changes, turns out I broke serialization with my change and a few other minor changes.

After that when I ran benchmarks, creation C++ is still king, but JS was much closer. In addition, in actual execution JS was dramatically faster than C++. Here are my post change results: https://gist.github.com/saem/a16cc64d45e7eaeb902c95170644ea16

The next issues that I looked at but couldn't see a quick fix for, was views. Oh man, structural typing really hurts performance. My first quick idea was using some sneaky conditional complication where the view type parameter is a typedef on a dynamic target to an anonymous structure otherwise it's a @:structInit class on static targets. But then I looked at the view macro and realized the expression macros made that painful and I didn't want to rewrite all that.

Ultimately the view is really a query (where clauses in something SQL-like) and maybe if that is declared semi-separately or something it might be a whole lot easier to either entirely remove the need for any wrapper whatsoever or build a concrete type at compile time so there isn't any overhead in static targets. I bet C++ and HashLink would take the lead then.

FYI, I stumbled upon Baldrick when I happened to be searching for a pure Haxe GJK implementation (found headbutt!). Your blog is awesome too, BTW.

saem avatar May 17 '20 08:05 saem