3 ms·
Profiling. If you're not profiling, you're completely wasting your time. The 1% is almost never where you think it is. And when you do identify the 1%, you nee
by rerdavies 4y ago
Profiling. If you're not profiling, you're completely wasting your time. The 1% is almost never where you think it is.
And when you do identify the 1%, you need to be testing optimizations with a profiler constantly while optimizing. Profile. Do some optimization. Profile again. Roll back if not successful. Repeat until done. It's impossible to optimize well if you're not doing profiling.
The ultimate tools would be either Intel's profiling tools, or ARM's profiling suite (both very expensive). But MSVC and GCC do a fantastic job of scheduling instructions to avoid pipeline stalls these days, so these deep profiling tools are unlikely to gain more than 2 or 3% performance increases these days. (Worthwhile pretty much only if you're writing GPU drivers for NVidia or AMD).
Taken as a given that 100% of your code is at least algorithmically correct in the first place. (Appropriately better than O(N^2) whenever possible).
- Former writer of graphics drivers, currently audio DSP engineer.
- anonymoushn 4y agoA hash table that accesses a minimum of 2 cache lines per query can be algorithmically correct and also admit a 100% speedup.
- themulticaster 4y agoI'm not familiar with how it compares to ARM/Intel's profiling tools, but I found the Linux perf suite to be very capable (though limited to Linux obviously). And Hotspot [1] allows effortless profile visualization using flame graphs, including some very interesting features such as off-CPU time profiling [2]. "perf record" coupled with Hotspot forms a very smooth edit-compile-profile cycle. [1] https://github.com/KDAB/hotspot https://github.com/KDAB/hotspot [2] https://github.com/KDAB/hotspot#off-cpu-profiling https://github.com/KDAB/hotspot#off-cpu-profiling
- rerdavies 4y agoAgreed. Linux perf tools are perfectly acceptable for all but the most ultra-extreme optimization tasks. VTune allows you to determine where pipeline stalls are occurring at the instruction level (for that last 2 or 3% gain in performance). I haven't worked with ARM profilers (way out of my price range), but I assume, given the exorbitant price, they provide the same sort of in-depth analysis. Probably a handful of people on the planet that need that kind of in-depth analysis.