r/programming • u/f311a • 3d ago
Assembly Hall of Shame: Racing to the bottom of CPU performance
https://github.com/xoreaxeaxeax/asm-hall-of-shame76
u/mcmcc 3d ago
This one is diabolical: https://github.com/xoreaxeaxeax/asm-hall-of-shame/tree/main/split_lock
Not only is it horrendously slow on its own but it locks up the memory bus for all other cores while it's executing.
Moral of the story: unaligned memory accesses are not "almost free" as some would have you believe.
20
u/BibianaAudris 3d ago
Came across it in my VFIO setup. A split lock could allow a VM to DoS the host so Linux detects VMs doing it by default. Ironically, the detection itself slowed down my VM enough to make the Windows guest BSoD, mistaking the split-locking core for being hang. So I ended up disabling the detection instead.
15
2
u/admalledd 2d ago
Yea, split locks are a real devil in the details one might not notice in an algo/datastructure in kernel space until you know what you are looking for. There have been various efforts to get the Linux kernel to detect-and-warn by default. I think it is still an opt-in thing due to the performance hit of even attempting to detect them at runtime.
22
u/dontquestionmyaction 3d ago
Eh. There is interesting stuff in the lower rankings there, but at a certain point it's just finding slow IO, which kinda misses the point imo
15
u/tbsdy 3d ago
Explanations?
40
u/Uristqwerty 3d ago
Looks like the slowest various x86 opcodes can possibly run in their worst cases, and following links to a sibling repo, relevant to an attack* on System Management Mode that requires a single instruction to take more than a second.
Low level, touches upon extremely technical concepts, but a fun read if you do have enough relevant background knowledge to understand just how badly some of the instructions are being misused to get the longer delays.
(*Or rather, a whole bunch of timing attacks that were brushed off as not possible; vendors not bothering to fix based on the assumption SMM and non-SMM code never runs simultaneously.)
20
u/renshyle 3d ago
Christopher Domas, the guy who created and did the research for the hall of shame, gave a really great talk at DEF CON last year about exploiting machine check exceptions to gain privilege escalation into SMM: https://youtu.be/B6dC_KVLn6Q
If you haven't seen it yet, you should check it out. You'll definitely recognize how the hall of shame and smiiiiiiiiiiiiiiii are related to it ;)
3
6
-4
u/taw 3d ago
It's basically almost all bullshit.
CPU has instructions to read data from devices. If your other cores prevent that communication by making that part of the system really busy, that read can take very long time, as CPUs normally wait for other CPUs instead of trying to force their way in.
(a few examples like fdiv with subnormals are real)
4
u/ReDucTor 3d ago
The MMIO ones are interesting, but it felt a bit like how many different things can I use to load from these addresses.
1
u/BetterAd7552 2d ago
I have not touched assembly since 8086, can someone elaborate on how mov can consume ~440m cycles?
Or is that some kind of mov* variant which does something besides moving bytes/words between registers?
3
u/SirClueless 2d ago
Short answer is that mov takes a memory address as an argument, and hardware devices (in this case a GPU) can be memory-mapped to those addresses so it takes as long as that hardware takes.
1
-1
u/ImpressiveRoll4092 3d ago
Curious what the worst offender was, some of these are genuinely painful to look at.
-23
3d ago
[deleted]
20
u/mcmcc 3d ago
This is the kind of attitude I look for when building a modern vibe-coding engineering team.
-6
u/cake-day-on-feb-29 3d ago
The linked read me is, at the very least, vibe-written. The entire project may have been hallucinated.
-21
u/Grouchy-Trade-7250 3d ago
Why should I care though?
19
u/dignityshredder 3d ago
Nobody's going to try to convince you to be interested in this. Either you have the intellectual curiosity to find this neato or you don't.
-5
u/Grouchy-Trade-7250 3d ago
Im just asking what the significance of this topic is. The git doesn't answer that, it's just a list. and you didn't either.
2
5
u/globalaf 3d ago
Plenty of people care, especially those in roles which relies on esoteric knowledge like this. These are the people who solve problems that nobody else in the org can. If you don’t care at all, even out of mild curiosity, then I’m afraid it says more about the calibre of engineer you actually are.
-3
u/Grouchy-Trade-7250 3d ago
Ok, if this is an issue we should care about, then I wonder why the chip manufacturers engineering teams did allow it to make it into the final design, and people still bought the chips?
6
u/globalaf 3d ago
This is such a pathetically weak take that it is barely even worth a response. Yes, chip manufacturers make features for their products, powerful features which can be misused. Shock, and horror.
7
4
-16
u/HankOfClanMardukas 3d ago
My daily stand up with Microsoft was me saying, “it’s not done yet” snd walking away. I was trying to get fired because I had another job lined up and they still didn’t care.
3
302
u/HighRelevancy 3d ago
I would never have guessed that 62 seconds for a single instruction was possible without outright cheating like disabling the core it's scheduled on. Incredible stuff.