I have a GUI program that is fairly snappy when in compiled in release mode but basically unusable in debug mode. I’ve done some profiling and narrowed the slow part down to a particular function. I want to know what the compiler did to make that function fast so I can make the program usable in debug mode. That is, I would like some Rust code that, when compiled in debug mode, will be some reasonable fraction of the speed of the release mode version of the code.
I understand that this may not be possible in general, but I would at least like to know how close I can get in a particular case. I’m also aware that I could enable optimizations in debug mode, or just live with when I actually need to use a debugger, but I’m still curious what the compiler did.
The first thing I can think of to do is comparing the debug and release mode assembly with godbolt.org . Are there other options? Is looking at an intermediate representation of the code like MIR or LLVM IR likely to be helpful here? Is there some compiler flag that will list optimizations performed on the code?