Noticable performance loss with State specific dispatchers?


First of all, Hello!

I usually hang out on Discord and harass the folks in the #help channel there, but I figured I can’t constantly hog the channel for every single question I have. So… here I am with my first post on here!

I implemented a State specific dispatcher, which for the most part works just fine. But the System s inside that dispatcher seem to get executed less frequently. I followed the example in the book and have the following update function in my State:

fn update(&mut self, data: &mut StateData<GameData>) -> SimpleTrans {;

I checked against an older implementation of my game which had a single dispatcher and when I printed time.delta_seconds() inside a System s run() function I’d get these values:


With the State specific dispatcher the System (which is part of the State dispatcher) prints the following:


When I comment out; in my update function I get similar values again… but I don’t think it’s a good idea to leave that part out.
I’m currently testing in debug mode… I could try release but I find the difference on debug bad enough and don’t want to rely on release for development.

My source code can be found here:

src/states/ has its own dispatcher.

Am I missing something or are State specific dispatchers simply slower?

1 Like

(Théo Degioanni) #2

You should try out running it in release mode first. Debug mode has sometimes surprising and hard to decipher performance issues as the underlying abstractions in Amethyst are very complex and are heavily optimized by release mode.

Of course having a state-specific dispatcher is somewhat slower as it has to run after the main dispatcher, separately. But it should not be that much slower.

1 Like


Thanks for your response! I actually just figured out what the problem was with the help of @distransient. Since I’m using the default GameData, the core dispatcher is already executed by the Application and thus the line; causes the core dispatcher to be executed twice before my custom State dispatcher. Removing; fixed it.



Created a PR to change that part in the master book:

1 Like