Brifing

Assembly Hall of Shame: Slowest CPU Instructions

When x86 architecture hits performance rock bottom

Hacker News2 min

1The quest for inverse performance

The Assembly Hall of Shame project takes an opposite approach to traditional optimization. Designed to measure the lowest possible performance of single x86 instructions, it reveals unexpected CPU bottlenecks and microarchitectural limits. Tests are conducted on factory-stock systems without hardware modifications, exposing processor behaviors under extreme conditions.

2fxrstor64 sets latency record

The record holder at 198 billion cycles is the fxrstor64 instruction. Loading 512-byte FPU/MMX/XMM state from high-latency MMIO region while hammer cores saturate the PCIe root complex creates this extreme queueing effect. This technique violates System Management Mode fundamentals by forcing non-posted transactions from GPU registers.

3The extended NOP variant

Ranking 27th at 20 cycles, the data16-prefixed NOP demonstrates how to consume CPU cycles without doing actual work. Tested on Intel Core i7-8559U, this instruction showcases x86's handling of redundant prefixes. Since regular NOP was too brief, an artificially lengthened version was employed for measurement.

4IDIV division trap

The 77-cycle IDIV example uses 128-bit dividend (rdx:rax=2:0) with small divisor to trigger the longest path through division microcode. This creates an astronomical division operation of 2^65/5 ≈ 7.4×10^18, stressing the processor's division unit design limits. Such tests reveal microarchitectural corner cases.

5ENTER instruction depth

The ENTER instruction at 112 cycles creates stack frames at maximum 31 nesting depth, forcing 30 display-pointer loads through microcode's display-walk path. Measured again on Intel Core i7-8559U, this technique demonstrates how complex stack operations can become performance bottlenecks in deep call hierarchies.

6Denormal number trap

The 133-cycle FLDL instruction loads denormal values (like 1e-310, DBL_MIN) to trigger FPU microcode assists. This tests floating-point unit's special case handling mechanisms. Denormals—values below normal range requiring special processing—often reveal subtle microarchitectural behaviors.

7CLFLUSH cache eviction

At 165 cycles, CLFLUSH instruction evicts dirty cache lines from L3, demonstrating cache coherency mechanism overheads. Such tests become particularly relevant in multi-core systems where cache management operations significantly impact performance. This reveals hidden costs of maintaining memory consistency.

8FSIN special value processing

The 257-cycle FSIN instruction operates on QNaN (Quiet Not-a-Number) values like 0x7fffffffffffffff, triggering microcode's special value handling path. Tests show positive/negative or NaN/inf variants don't differ significantly, providing insights into floating-point unit's edge-case behaviors.

9MFENCE write congestion

The 326-cycle MFENCE instruction was tested after saturating write-combining buffers with MOVNTI stores to 16 distinct cache lines. This forces MFENCE to drain all pending LFB writes to uncore, measuring memory barrier overheads. Such tests quantify synchronization instruction costs in memory hierarchies.

10CPU architecture boundaries

Assembly Hall of Shame serves as crucial reference for CPU designers, showing how unexpected instruction combinations can create extreme latencies. These insights benefit both security researchers and performance engineers. The project offers unique window into x86 architecture complexity, informing future processor designs and optimization strategies.

Original article: Hacker News — Assembly Hall of Shame: En Yavaş CPU Talimatları