News for hackers. Stuff that matters.
Re:You Can't Fool the Optimizer by Scene_Cast2 on Wednesday December 03, 2025 @08:11AM (#46134095)
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.

Re:You Can't Fool the Optimizer by layer8 on Wednesday December 03, 2025 @10:43AM (#46135783)
I don’t disagree, but profiling also won’t help you with death by a thousand indirections.
Re:You Can't Fool the Optimizer by lmm on Wednesday December 03, 2025 @09:09PM (#46142940)
Sure, but that's mostly a myth.
Re:You Can't Fool the Optimizer by 1718627440 on Friday December 05, 2025 @04:49AM (#46159137)
So how do you see in a profiler, that everything is 1.2x slower than it could be?
Re:You Can't Fool the Optimizer by lmm on Friday December 05, 2025 @11:15PM (#46170627)
No-one's getting out of bed for 1.2x.
Re:You Can't Fool the Optimizer by 1718627440 on Saturday December 06, 2025 @11:51AM (#46174719)
Depends. 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.
Re:You Can't Fool the Optimizer by lmm on Sunday December 07, 2025 @03:34AM (#46180151)
> 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.

Re:You Can't Fool the Optimizer by 1718627440 on Sunday December 07, 2025 @09:33AM (#46181930)
In 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.
Re:You Can't Fool the Optimizer by teworks on Sunday December 07, 2025 @05:35PM (#46185993)
I 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.