> The most surprising thing for me is how unintuitive it is to optimize Rust code given that it’s honestly hard to find a Rust project that doesn’t loudly strive to be “blazingly fast”. No language is intrinsically fast 100% of the time, at least not when a mortal like me is behind the keyboard. It takes work to optimize code, and too often that work is guess-and-check.<p>I get the feeling that a lot of Rust projects claim to be "blazingly fast" just because they are written in Rust, and not because they've made any attempts to actually optimize it. I rarely see any realistic benchmarks, and the few times I've looked deeply into the designs they are not implemented with execution speed in mind, or in some cases prematurely optimized in a way that is actively detrimental [1].<p>Personally I think it's because so many of the new Rust programmers are coming from scripting languages, so everything feels fast. I don't have any problems with that, but I'd advise anyone seeing a "blazingly fast" Rust project to check if the project has even a single reasonable benchmark to back that up.<p>[1] <a href="https://jackson.dev/post/rust-coreutils-dd/" rel="nofollow">https://jackson.dev/post/rust-coreutils-dd/</a>
Every Linux C/C++/Rust developer should know about <a href="https://github.com/KDAB/hotspot" rel="nofollow">https://github.com/KDAB/hotspot</a>. It's convenient and fast. I use it for Rust all the time, and it provides all of these features on the back of regular old `perf`.
> In order to get any useful results I had to run my Advent of Code solution 1000 times in a loop<p>Yeah that's my general problem with all these flamegraphs and other time based tools. There's a bunch of noise!<p>I'd image for something with deterministic GC (or hell no-gc) you should be able to get a "instruction count" based approach that'd be much more deterministic as to what version of the code is fastest (for that workflow).
Talking of data driven, I think I read that the rust compiler team checks itself against some massive list of popular crates to check it doesn't break anything.<p>Would it be a reasonable use of resources to run all those test suits and identify hot spots for community wide optimization?
An often overlooked option for profiling Rust is Apple's Instruments.app. It's amazing and usually the first thing I reach for when I need a profiler on Mac OS X.
My key take away from this is different - be very sceptical of third party packages! Both performance issues were traced back to them, and his replacement of their functionality - while not being "battle tested" and surely constituting "re-inventing the wheel" - were faster, easy to read, and easy to understand.<p>Any front-end devs reading this? :)
I'm surprised there aren't CPU emulators that are just for collecting performance information.<p>Edit: Maybe something like this: <a href="https://github.com/guillon/run-qemu-profile" rel="nofollow">https://github.com/guillon/run-qemu-profile</a>