5 ms·
This post assumes C/C++ style business logic code. Anything HPC will benefit from thinking about how things map onto hardware (or, in case of SQL, onto data st
by Scene_Cast2 10mo ago
This post assumes C/C++ style business logic code.
Anything HPC will benefit from thinking about how things map onto hardware (or, in case of SQL, onto data structures).
I think way too few people use profilers. If your code is slow, profiling is the first tool you should reach for. Unfortunately, the state of profiling tools outside of NSight and Visual Studio (non-Code) is pretty disappointing.
- layer8 10mo agoI don’t disagree, but profiling also won’t help you with death by a thousand indirections.
- lmm 10mo agoSure, but that's mostly a myth.
- 1718627440 10mo agoSo how do you see in a profiler, that everything is 1.2x slower than it could be?
- lmm 10mo agoNo-one's getting out of bed for 1.2x.
- 1718627440 10mo agoDepends. If you have a real-time system, that might very well will be what you chase after. Also why not make your program a bit faster when it is no work, by starting it the right way upfront. I mean I wouldn't rewrite a program for this, but when I program some new part and I can avoid an indirection, why not do it? Less complexity, less (failure) state, better performance.
- lmm 10mo ago> If you have a real-time system, that might very well will be what you chase after. If you have a real-time system you care about the difference between real-time and not. But any given 1.2x factor is extremely unlikely to be the difference-maker. > When I program some new part and I can avoid an indirection, why not do it? Less complexity, less (failure) state, better performance. Well if it makes the code simpler then you should do it for that reason. But thinking about this kind of low-level performance detail at all will usually do more harm than good.
- 1718627440 10mo agoIn languages that don't hide much (e.g heap allocations in Java), less complexity corresponds to better performance (up to a point). Because better performance is fundamentally about letting the computer do less work. When pointer indirection is explicit, the programmer is nudged towards thinking whether they actually want it. Same with dynamic dispatch, polymorphism and every other runtime complexity.
- teworks 10mo agoI know games are constantly brought up as an example, but it's for good reason. Your frametime being 16.6ms instead of 20ms is the difference between a shipped feature and a cut one in a console title. And all the data and instruction cache thrashing caused by pointer chasing can (and does) absolutely make that difference.