We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
RustConf 2023 - Using Rust and Battlesnake to never stop learning
Learn how a Ruby developer leveraged Rust and Battlesnake to optimize simulation performance, improve code efficiency, and develop a competitive snake by exploring best practices and overcoming challenges.
- The speaker, a Ruby web developer, chose Rust for their Battlesnake development, enjoying the experience and appreciating the compiler’s safety and speed.
- The speaker’s first snake was simple, only considering the current board state, but with the introduction of Rust, they were able to create a more complex snake.
- Clone calls were a major issue, taking up a significant amount of time, until the speaker used the compact representation, which was cheaper to clone.
-
Flamegraphs were used to identify slow functions, pointing out the need to speed up
make_move
andreverse_move
. - By removing clone calls, the speaker was able to speed up their snake’s simulations.
- The speaker then used the flamegraph knowledge to identify low-hanging fruit and make further improvements.
- Rust helped the speaker understand data ownership and lifetimes better.
- The speaker used MinMax, a specific tree search algorithm, which worked well, but then optimized it for a small memory footprint and fast simulation.
- The speaker was able to use Rust to optimize for memory usage and speed, leading to significant improvements in simulation performance.
- The final product was a fast and efficient snake, capable of simulating moves and making decisions quickly.
- The speaker was able to analyze and improve their code using Rust, leading to better performance and a more competitive snake.