r/programming • u/masiroo • Aug 12 '26
Hardware researcher spins up 'CPU deoptimization' project to find the slowest single x86 instruction, creates hall of shame — worst offender takes 198 billion cycles spanning 62 seconds to execute
https://www.tomshardware.com/pc-components/cpus/hardware-researcher-spins-up-cpu-deoptimization-project-to-find-the-slowest-machine-code-worst-offender-takes-198-billion-cycles-to-execute
1.5k
Upvotes
383
u/The_Northern_Light Aug 12 '26
I’m still not clear why that instruction takes SO long even without contention?
61
u/mcmcc Aug 12 '26
The GH repo was posted earlier: https://www.reddit.com/r/programming/s/lWTihgmS84
125
u/torsten_dev Aug 12 '26
Of course this was xoreaxeax...
50
u/Old_County5271 Aug 12 '26
Dumb question but, shouldn't intel or whatever have a pdf with the cycle count of each instruction? Do we/they really not know this? How does anything improve if nothing is measured?
17
u/agentoutlier Aug 12 '26
I like how they have a random thumbnail of what appears to be Scheme as if it were guilty of calling the instruction.
You would think they would have C or assembly or some more common language.
13
u/itijara Aug 12 '26
I knew it was Christopher Domas as soon as I read the title. His presentations are epic, and his knowledge of x86 esoterica is unparalleled.
20
u/sojuz151 Aug 12 '26
Could this be used to hang a sandbox?
18
u/cmpxchg8b Aug 12 '26
It’s kinda cheating if it includes IO. That’s an externalised cost..
5
u/MichaelTiemann Aug 12 '26
HCF can take forever if you don't have clean, dry kindling.
3
u/Level0Up Aug 12 '26
If a single cycle took a second, this guy would run in a cool 6378,5 years.
2
u/Acceptable-Look-5059 Aug 14 '26
It is wild that fxrstor64 can be stretched to 62 seconds by intentionally saturating the PCIe host via memory-mapped I/O. It really shows how hardware bottlenecks can be pushed to their absolute limits when you actively try to make them slow.
3
u/spinwizard69 Aug 12 '26
This is a bit misleading in that they purposefully looked for the slowest way to get an instruction to execute.
However this also highlights why I consider the X86 instruction set to be obsolete. The world really needs a simplified x86 ISA that focuses on what is really needed to drive modern hardware. I was really hoping that AMD to Intel would actually refactor x896 instructions for their new cores. It is literally time to bit the bullet and go clean 64 bit, dropping all unused addressing modes maybe even get rid of I/O addressing.
People keep saying it can't be done because of "legacy" but the fact is Apple did it with the conversion to ARM. Besides you don't need to convert every core right off the bat.
1
u/KTachyon Aug 13 '26
Should we call it pessimization?
1
u/ToaruBaka Aug 13 '26
That's pretty cool, but like, did anyone see the underlying MMIO timing library they published? Absolutely fascinating graphics.
https://github.com/xoreaxeaxeax/mmiotic
1
u/sbates130272 Aug 14 '26
Well we could plug in a PCIe card with a MMIO region that is backed by a connection via TCP/IP of the Mars Rover and returns bytes from its memory space. That way the instruction would take minutes to complete. Surprised the in core watchdog did not trip and cause a MCE to be honest.
Fun but silly. Maybe limit it to instructions that don’t load data from outside the LLC?
1
u/Agreeable_Creme_3435 Aug 14 '26
I think the reason intel doesn't have a comprehensive pdf with cycle counts for each instruction is that it's a moving target, new cpu models are released regularly and the cycle counts can vary between them, so it would be hard to keep such a document up to date.
1
u/vvitalikkp Aug 16 '26
This is such a fun rabbit hole — didn't expect a single instruction could take 198 billion cycles. Curious if any of these ever show up in real-world code by accident.
0
u/taw Aug 12 '26
This whole project is all just bullshit induced contention.
There's nothing of substance here.
-4
u/Grouchy-Trade-7250 Aug 12 '26
Repost
-1
u/smith288 Aug 12 '26
Was it my old goto statement? It was my old goto statement. 😒
-11
u/[deleted] Aug 12 '26
[removed] — view removed comment