5 ms·
Didn't Intel bork PAUSE on some CPUs? IIRC it can take 140 cycles to execute.
by secondcoming 5y ago
Didn't Intel bork PAUSE on some CPUs? IIRC it can take 140 cycles to execute.
- usefulcat 5y agoIn skylake, they increased the duration of pause from "about 10 cycles" to "as many as 140 cycles". https://aloiskraus.wordpress.com/2018/06/16/why-skylakex-cpus-are-sometimes-50-slower-how-intel-has-broken-existing-code/ https://aloiskraus.wordpress.com/2018/06/16/why-skylakex-cpu...
- dragontamer 5y agoI don't think that's really a "bork" though. 1. PAUSE should only be executed inside of the spinlock. 2. Fast-path won't touch the "PAUSE" instruction. (Ex: lock is unlocked. So you grab the lock, bypass the while loop and carry on). 3. Slow-path is... well... the slow-path. You'll be spinning in there for thousands of cycles, waiting for "the other thread". Saving power by effectively "sleeping" a bit longer isn't a big issue. ----- I very well could assume that Intel did the measurements, and that PAUSE with 100+ delay of latency was higher performance / throughput than their original PAUSE implementation. It is a "slow-path" instruction after all. If the spin-lock has any contention what-so-ever, you're looking at 100+ cycles to even communicate to L3 cache (~40-nanoseconds == 160 cycles to talk to L3 cache at all). It makes no sense to be "any faster" than this, because L3 cache hasn't changed yet. You might as well sleep until the next point-in-time where L3 cache had a chance to update (aka: the value of the spinlock has changed). L2 cache and L1 cache are "private" to each core, so its impossible for another core to change the values in L1 or L2. So the "closest" the spinlock's value can be is L3 cache. The only exception I can think of... is if both threads are SMT/Hyperthreads on the same core. This case has probably gotten slower, but all other cases have probably gotten faster (or more precisely: higher throughput).