Comment by pclmulqdq

Comment by pclmulqdq a day ago

21 replies

-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.

arthur2e5 a day ago

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.

  • hedora a day ago

    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.

  • pclmulqdq 21 hours ago

    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.
mgaunard a day ago

My desktop computer is a Sandy Bridge from 2011. I still haven't seen any compelling reason to upgrade.

  • bigstrat2003 18 hours ago

    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.

  • alberth a day ago

    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...

    • jpc0 a day ago

      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.

      • Aurornis a day ago

        > 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.

      • alberth a day ago

        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.

        • mgaunard 10 hours ago

          I did get a PCI-Express to M2 adapter and installed an NVMe drive.

          That was indeed the biggest upgrade ever.

      • LtdJorge 21 hours ago

        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.

    • genter a day ago

      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.

ksec a day ago

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.

cassepipe 21 hours ago

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.

wffurr a day ago

The default is an even older instruction set. Maybe you meant to suggest -march native ?

ericpauley a day ago

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).