5 ms·
-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 de
by pclmulqdq 1y ago
-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.
- ericpauley 1y agoThis 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).
- arthur2e5 1y agoThe 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 https://godbolt.org/z/oof145zjb So no, Haswell is not the problem. LLVM just doesn't know about the dependency thing.
- hedora 1y agoAlso, 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.
- sgerenser 1y ago"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.
- pclmulqdq 1y agoOh, 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 1y agoMy desktop computer is a Sandy Bridge from 2011. I still haven't seen any compelling reason to upgrade.
- alberth 1y agoWhat 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-i7-2600k https://browser.geekbench.com/processors/intel-core-i9-14900ks https://browser.geekbench.com/processors/intel-core-i9-14900...
- jpc0 1y agoBecause 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.
- alberth 1y agoAgreed 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 1y agoI did get a PCI-Express to M2 adapter and installed an NVMe drive. That was indeed the biggest upgrade ever.
- Aurornis 1y 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.
- wffurr 1y agoThe default is an even older instruction set. Maybe you meant to suggest -march native ?
- ksec 1y agoNot 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 1y agoI 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.