News for hackers. Stuff that matters.
Re:When O3 is 2x slower than O2 by pclmulqdq on Sunday November 02, 2025 @07:46AM (#45789918)
-O3 -march=haswell

The second one is your problem. Haswell is 15 years old now. Almost nobody owns a CPU that old. -O3 makes a lot of architecture-dependent decisions, and tying yourself to an antique architecture gives you very bad results.

Re:When O3 is 2x slower than O2 by arthur2e5 on Sunday November 02, 2025 @07:58AM (#45789957)
The author gives a godbolt link. It takes 5 minutes to add two compilers on raptorlake and see that it gives the same result.

https://godbolt.org/z/oof145zjb

So no, Haswell is not the problem. LLVM just doesn't know about the dependency thing.

Re:When O3 is 2x slower than O2 by hedora on Sunday November 02, 2025 @09:49AM (#45790715)
Also, if you’re building binaries for redistribution, requiring Haswell or newer is kind of an aggressive choice.

I have a box that old that can run image diffusion models (I upgraded the GPU during covid.)

My point being that compiler authors do worry about “obsolete” targets because they’re widely used for compatibility reasons.

Re:When O3 is 2x slower than O2 by sgerenser on Tuesday November 04, 2025 @01:24PM (#45814212)
"Haswell or newer" is a bit misleading here, because there were low-end Celerons and Pentiums shipped for years after the release of Haswell that lacked AVX2 and wouldn't be able to run software compiled for -march=haswell.
Re:When O3 is 2x slower than O2 by pclmulqdq on Sunday November 02, 2025 @11:43AM (#45791563)
Oh, yeah. Looking at the code the comparison function is bad in a way that will hit issues with cmovs. The "else if" there is a nearly 100% predictable branch which follows a branch that's probably completely unpredictable. One optimization you get with -O3 is that branches not marked likely or unlikely can be turned into dataflow. The proper ordering for that code is to pull the equality check forward into an if statement and mark with "unlikely" if you're using -O3, and then return the ordering of the floating point comparison.

Since we're using Rust there's some decent syntactic sugar for this function you can use instead:

    let cmp = |other: &Neighbor| -> Ordering {
        other.dist.partial_cmp(&neighbor.dist).unwrap()
            .then_with(|| other.id.cmp(&neighbor.id))
    };
You probably won't get any CMOVs in -O3 with this function because there are NaN issues with the original code.
Re:When O3 is 2x slower than O2 by mgaunard on Sunday November 02, 2025 @08:12AM (#45790051)
My desktop computer is a Sandy Bridge from 2011. I still haven't seen any compelling reason to upgrade.
Re:When O3 is 2x slower than O2 by alberth on Sunday November 02, 2025 @08:22AM (#45790127)
What factors would be compelling to upgrade for?

Just curious, since perf alone doesn’t seem to be the factor.

https://browser.geekbench.com/processors/intel-core-i7-2600k

https://browser.geekbench.com/processors/intel-core-i9-14900...

Re:When O3 is 2x slower than O2 by jpc0 on Sunday November 02, 2025 @08:27AM (#45790181)
Because number bigger doesn’t translate to higher perceived performance…

The only compelling reason that I want to upgrade my Sandy Lake chip is AVX2.

So it is instruction set not perf, sure there will be improved performance but most of the things that are actually performance issues is already handed off to the GPU.

On that note probably rebar and PCIe4 but those aren’t dramatic differences, if CPU is really a problem (renders/compilation) then it gets offloaded to different hardware.

Re:When O3 is 2x slower than O2 by LtdJorge on Sunday November 02, 2025 @11:40AM (#45791539)
I went from a Sandy Bridge (i5 2500k) to a Ryzen 9 3950x, and the perceived performance improvement was insane. You also have to take into account RAM and PCIe generation bumps, NVMe, etc.
Re:When O3 is 2x slower than O2 by Aurornis on Sunday November 02, 2025 @09:06AM (#45790461)
> Because number bigger doesn’t translate to higher perceived performance…

When the numbers are that far apart, there is definitely room to perceive a performance improvement.

2011 era hardware is dramatically slower than what’s available in 2025. I go back and use a machine that is less than 10 years old occasionally and it’s surprising how much less responsive it feels, even with a modern high speed SSD drive installed.

Some people just aren’t sensitive to slow systems. Honestly a great place to be because it’s much cheaper that way. However, there is definitely a speed difference between a 2011 system and a 2025 system.

Re:When O3 is 2x slower than O2 by cassepipe on Sunday November 02, 2025 @11:54AM (#45791657)
Especially on single core, everything is painfully slow. Tried to install linux on a ppc imac G5 five years ago and I had to admit that it was never going to be a good experience, even for basic usage
Re:When O3 is 2x slower than O2 by hedora on Sunday November 02, 2025 @09:55AM (#45790758)
Choice of things like desktop environments matters a lot. I’m using xfce or lxde or something (I can’t tell without checking top), and responsiveness for most stuff is identical between 2010 intel and a ryzen 9.

The big exceptions are things like “apt get upgrade”, but both boxes bottleneck on starlink for that. Modern games and compilation are the other obvious things.

Re:When O3 is 2x slower than O2 by Aurornis on Sunday November 02, 2025 @11:31AM (#45791473)
> The big exceptions are things like…

> Modern games and compilation are the other obvious things.

I mean if we exempt all of the CPU intensive things then speed of your CPU doesn’t matter

I don’t have a fast CPU for the low overhead things, though. I buy one because that speed up when I run commands or compile my code adds up when I’m doing 100 or 1000 little CPU intensive tasks during the day. A few seconds or minutes saved here and there adds up multiplied by 100 or 1000 times per day. Multiply that by 200 working days per year and the value of upgrading a CPU (after over a decade) is very high on the list of ways you can buy more time. I don’t care so much about something rendering in 1 frame instead of 2 frames, but when I type a command and have to wait idly for it to complete, that’s just lost time.

Re:When O3 is 2x slower than O2 by estimator7292 on Sunday November 02, 2025 @09:47AM (#45790702)
Believe it or not, "good enough" often is good enough. Regardless of how big the numbers are.
Re:When O3 is 2x slower than O2 by Aurornis on Sunday November 02, 2025 @11:25AM (#45791423)
The comment claimed there wasn’t a perceivable difference

That’s different than acknowledging that newer hardware is faster but deciding current hardware is fast enough

Re:When O3 is 2x slower than O2 by alberth on Sunday November 02, 2025 @08:54AM (#45790388)
Agreed that if you’re not using NVMe (as example), that non-CPU upgrade will translate into the biggest perceived benefit.

Then again, not many Sandy Bridge mobo supported NVMe.

Re:When O3 is 2x slower than O2 by mgaunard on Sunday November 02, 2025 @10:52PM (#45795698)
I did get a PCI-Express to M2 adapter and installed an NVMe drive.

That was indeed the biggest upgrade ever.

Re:When O3 is 2x slower than O2 by genter on Sunday November 02, 2025 @08:35AM (#45790239)
Not OP, but I'm on a 10 year old laptop.

Only thing I'd want is a higher resolution display that's usable in daylight, and longer battery life.

Re:When O3 is 2x slower than O2 by bigstrat2003 on Sunday November 02, 2025 @02:45PM (#45792843)
For what it's worth, you may be pleasantly surprised by the performance if you upgrade. I went from an Ivy Bridge processor to a Zen 3 processor, and I found that there were a lot of real world scenarios which got noticably faster. For example, AI turns in a late game Civ 6 map went from 30s to 15s. I can't promise you'll see good results, but it's worth considering.
Re:When O3 is 2x slower than O2 by ericpauley on Sunday November 02, 2025 @07:56AM (#45789947)
This era of CPUs has held up surprisingly well. I built an Ivy Bridge desktop in 2012 that still sees daily productivity use (albeit with an NVMe and RAM upgrade).
Re:When O3 is 2x slower than O2 by wffurr on Sunday November 02, 2025 @09:02AM (#45790426)
The default is an even older instruction set. Maybe you meant to suggest -march native ?
Re:When O3 is 2x slower than O2 by ksec on Sunday November 02, 2025 @09:06AM (#45790462)
Not as old but I am still typing this on a MacBook Pro Early 2015 with a Broadwell CPU. It is doing pretty well with Chrome and Firefox, not so much with Safari.
Re:When O3 is 2x slower than O2 by cassepipe on Sunday November 02, 2025 @11:51AM (#45791630)
I do. Had to replace the plastics of the laptop and the screen's definition is unacceptable but with Linux and a SSD it's still fine for basic computer usage. Not my daily driver but kept it as a daily drivers for 10 years.