Making Day 14 Part 2 3,000 TIMES FASTER with Flamegraphs | Advent of Code 2022 in Rust with Corey

2023-01-12
Hey I’m Corey and I’ve been writing Rust in my free time for a few years and recently started streaming some of my coding. I'm almost a month late with this now, but better late than never! Yesterday I filmed Day 14 Part 2, and at the end of the video I took a sec trying to see what might be making my code slow. I said that I could profile it and make a flamegraph but decided against it. Well about an hour after filiming I got curious and made a flamegraph! And wow, was I surprised. One small tweak and my solution was running THREE THOUSAND TIMES faster! In this video we walk through the problem, and then we use `cargo-flamegraph`: https://github.com/flamegraph-rs/flamegraph We also learn how to use `#[inline(never)]` to hint to Rust to keep functions in the stack trace which can help in finding things that might have been inlined! Check out my Github Sponsors to support me so I can keep making videos! https://github.com/sponsors/coreyja The Github Repo can be found here: https://github.com/coreyja/advent-of-code-2022 Advent of Code Site: https://adventofcode.com/2022 ----------- Day 1: https://youtu.be/Hy-trhtOglE Day 2: https://youtu.be/2ZmRad7DEuE Day 3: https://youtu.be/ijesnQhno9E Day 4: https://youtu.be/YHGaR7lwjqA Day 5: https://youtu.be/icgFLnyWaX0 Day 6: https://youtu.be/mW8ygbFwA9Y Day 7: https://youtu.be/0SPxVN1qYrg Day 8: https://youtu.be/Yz3CM2OrdcI Day 9: https://youtu.be/m06b3UHaifA Day 10: https://youtu.be/VFFyV-lW31E Day 12 Session 1: https://youtu.be/jviZ_B3rt1I Day 12 Session 2: https://youtu.be/Ad9KDVFjVzQ Day 12 Session 3: https://youtu.be/zPMZI1gN99o Day 13: https://youtu.be/MdUG-8UKHoc Day 14 Part 1: https://youtu.be/lMTwHbjm6ok

coreyja weekly

My weekly newsletter tailored at developers who are eager to grow with me!
Every week will be unique, but expect topics focusing around Web Development and Rust