impi icon indicating copy to clipboard operation
impi copied to clipboard

Increase performance

Open m9dfukc opened this issue 7 years ago • 2 comments

A fairly naive question, is there a way to increase the performance of this library?

I did a quick performance check; instantiating 2500 rotating bunnies which results in 15fps on my MacBook. In comparison with imperative pixi.js which takes ~ 140.000 instances to get that low in fps.

I see that having a immutable data structure has to come with a cost, but are there any cheep "tricks" I can apply? ... I like the whole concept of this library quite a lot ;)

edit: source code of the performance test

m9dfukc avatar Sep 25 '17 09:09 m9dfukc

Sorry for taking so long to answer. The short answer is that this library is never going to be as fast as using mutable objects, especially when all the sprites on screen are moving. However, there is still plenty of room for improving what's already there.

For example, CSS allows simple animations to be specified, so it may be possible to do the same with Impi. We could allow objects to be assigned a velocity, which would automatically update the position.

For my own purposes, I don't find the current limitations too onerous. ~1000 moving sprites on screen is a limit I doubt I'll get anywhere close to breaching, and I'll run into other bottlenecks (like network bandwidth) way before then.

weavejester avatar Dec 09 '17 12:12 weavejester

Thank you for the clarification. To be honest, I expected this kind of answer ;)

I was evaluating Impi for use in a media art installation where I had to move around several thousand objects every frame. In the end I used imperative pixi.js with object pools to avoid GC as much as possible. Of course everything comes with a cost ... the code got really ugly in the end, supposably also because of the very tight deadline. Currently I am working on a second iteration and I am back at reevaluating Impi, now that I know the ins and outs of the project ;)

m9dfukc avatar Dec 10 '17 15:12 m9dfukc