Slow performance when dispatching a large number of events

Kyle's Avatar


25 Jul, 2013 02:16 AM

I'm working on creating a game and have a game loop that runs once per second. In this loop I perform some simple calculations based on data in my data model, then update the model with the new values, and dispatch an event out to the context to let the other actors know about the new data. I have a handful of mediators that listen for this update notification and update their views accordingly (nothing crazy, mostly updating the values of some textfields). So the problem is that since I've started dispatching this update notification each second I have started seeing a pretty huge performance drop in my application (rollover states lag, minor animations become choppy, etc.). I'm wondering if there is anything I can do to improve the performance?

I have seen some suggestions that using Signals may be faster, and also saw a post from Stray ( that mentioned "turn the automated stage listening off" but I'm not really sure what that means.

Any feedback would be appreciated!



  1. Support Staff 1 Posted by creynders on 25 Jul, 2013 06:35 AM

    creynders's Avatar

    Swapping to signals won't make a lot of difference in this case, I think. I'm pretty certain that one of the views is doing some heavy lifting.
    That said, I wouldn't use Robotlegs for the game itself, but everything surrounding it: high scores, loading screens, etc. It's an application framework, not a game framework, and wasn't built for speed, but to alleviate a lot of the pain that rises when creating large, modular applications.

  2. 2 Posted by Kyle on 25 Jul, 2013 03:15 PM

    Kyle's Avatar

    So what would you suggest if this wasn't a game but an application that simply needed to update its' views every second (by dispatching an event from the model)? I say this, cause that is essentially what is happening. This isn't a game in the sense that it has a bunch of animation, frame updates, moving characters, tons of objects to track, etc.. It is a resource management "game" so basically we're just performing calculations on some data and updating the views with it. So given that, would you still say that Robotlegs isn't built to handle this type of updating (on an every second basis)?

    If not, any suggestions on other ways I might go about handling these updates? Also, any pointers on general performance tuning for RL (i.e. would having less injections in a particular actor improve performance? ..etc)

    Thanks as always!

  3. Support Staff 3 Posted by Shaun Smith on 25 Jul, 2013 03:26 PM

    Shaun Smith's Avatar

    Something else must be going on here. You should be able to dispatch thousands of events every frame before it starts affecting performance. A couple of hundred events every second should be entirely negligible. Switching to Signals won't make a difference in this case. You need to do some performance profiling to see what is slowing things down.

  4. Support Staff 4 Posted by Shaun Smith on 25 Jul, 2013 03:27 PM

    Shaun Smith's Avatar

    Bear in mind that setting text is a very slow operation. Always check to see that the value has changed before setting the text on a textfield.

  5. 5 Posted by Kyle on 25 Jul, 2013 03:46 PM

    Kyle's Avatar

    Yeah, I think that is the next step (performance profiling). Thanks Shaun (and creynders, what is your first name btw!? Feel kinda funny always typing creynders haha).

    As to your note on textfield updates, I wonder if getting down to a more base-level text object would improve performance.

    Feel free to throw out any other performance gotcha's you might have!

    Thanks again guys!

  6. Support Staff 6 Posted by creynders on 25 Jul, 2013 04:27 PM

    creynders's Avatar

    Be sure to check the calculations too. Mistakes slip easily into
    loops within loops for instance. First determine what exactly is causing
    the lag, then find out how to improve it.

    And my first name is Camille. Yeah, my parents thought it was funny to give
    a female name to their son :)

  7. 7 Posted by Kyle on 25 Jul, 2013 05:06 PM

    Kyle's Avatar

    Haha. We could give you a gangster ass nickname like "C-Murder" or "Camilla the Killa" if that helps.. ;-)

    I'll check out calculations for sure. I'm also trying to use Adobe Scout to help with profiling.. Interesting tool (just not sure what half the data means yet haha).

    Thanks again "C-Rex!"

  8. Support Staff 8 Posted by creynders on 25 Jul, 2013 05:26 PM

    creynders's Avatar

    Hey, hey, it's Camill*e*, not Camill*a*! Don't make it even worse! ;)
    No, in reality it _is_ a men's name too. Funny thing is, w/o realizing it,
    I did the same to my son Akira. Many people think it's a women's name.
    He'll be receiving a lot of "dear miss" letters too, just as I did/do.

  9. Ondina D.F. closed this discussion on 30 Aug, 2013 07:59 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac