iolivia/rust-sokoban

Performance Issues due to Debug Mode

Opened this issue · 2 comments

Section 3.4 states that the game is running slowly due to unbatched draw calls, but the reality is that rust's debug mode is very slow. Compiling in release mode or turning on optimizations when compiling in debug mode will make the game much faster. I added the following to make rust optimize in debug mode:

[profile.dev]
opt-level = 2

Here's a table with the performance I got with the various techniques:

Optimizations Spritebatching FPS
No No 7 fps
No Yes 47 fps
Yes No 144 fps
Yes Yes 144 fps

I know of this technique from following (and occasionally contributing to) veloren, which is a good example of how specs can be used to make a larger game.

@desttinghim this is super interesting, thanks for the thorough analysis. it's pretty insane the effect the debug optimizations have. this was all with cargo run or cargo run --release? I would be curious to see how batching does in release mode, I think I was using release throughout the whole book. The optimisations flag would not do anything in release right?

This was all with cargo run. The optimizations flag won't do anything in cargo run --release, since only [profile.dev] is changed. You can read more about profiles here: https://doc.rust-lang.org/cargo/reference/profiles.html

Something I should probably note is that my screen refreshes at 144hz, which is why I got 144 fps instead of 60.