The better tool is to profile the code, then optimize hotspots. There's a Rust Performance Book with a list of profilers known to work with Rust programs[1]. Rustc does support Profile Guided Optimization[2] which is often pretty good at speeding up the output even without any code changes.
[1] https://nnethercote.github.io/perf-book/profiling.html [2] https://doc.rust-lang.org/rustc/profile-guided-optimization....
> The simplest tool is to just grep for various constructs that copy or allocate.
Do you happen to have a curated list somewhere?
Not sure of a list for things that copy their data. The Clone trait is the obvious one, and it requires calling clone() to make the copy. EG `val.clone()`. So searching for `.clone()` will get you those. But other things like to_string are expensive, and From/Into are sometimes expensive.
[1] https://docs.google.com/presentation/d/1q-c7UAyrUlM-eZyTo1pd...
That's 100% correct but there's one problem: how do you write down your future improvement opportunities?
Skip 2 optimizations here, 3 optimizations there and after 30 PRs you can easily have notes spanning 100 bullet points on what to optimize one day in the future Soon™.
I am still not at what I'd call an expert level in Rust -- and the skill ceiling is quite high -- so maybe with time I'd start to automatically spot these optimization opportunities?
But before I am at that level I'd prefer to either keep hugely long notes or, ideally, have a tool recommend optimizations to me.