Why false sharing alignment should be 128 bytes on x64

39 points by monoid


0x2ba22e11

I'm willing to bet that Apple Silicon processors have some mechanism to prevent cache pong when two cores are using values in adjacent 64-byte blocks for two reasons. Firstly, they are frequently used to emulate amd64 CPUs which have 64-byte cache lines, and exhibiting cache pong (that the emulated CPU wouldn't have) would make them very bad at it. Secondly, lots of code in the wild hardcodes the assumption that cache lines are 64 bytes long for the purpose of cache pong prevention, so making the chip perform as though this is true is necessary for it to run existing software fast.

(Sure you're supposed to query sysconf(_SC_LEVEL1_DCACHE_LINESIZE) at runtime but people certainly don't always.)

radex

This is beside the main point but:

This text was written by Ivan Boldyrev. No hallucinations, no slop, no homogenization. I used AI only for brainstorming and proofreading.

I think it should become the norm to say that. I have no interest in reading AI-written posts, but in this day and age, I always need to be on the lookout for those. (On my site, I added a small "Human-written" on top of each post. I think it's better than on the bottom - start with a promise, instead of disclaiming after the text had been read)