2

the cacheline size on the most hardware is 64 bytes。

I don’t know why the @Contened pad 128 bytes before and after the field or object ?

and i have tried to read the following two articles to relieve my confusion。

Pessimistically handling the case of enabled adjacent cache line prefetchers

Note that we use 128 bytes, twice the cache line size on most hardware to adjust for adjacent sector prefetchers extending the false sharing collisions to two cache lines

they all said the reason why use 128 bytes is to adjust for adjacent sector prefetchers extending the false sharing collisions to two cache lines。

but what's the the case of enabled adjacent cache line prefetchers ?

bin
  • 51
  • 6

1 Answers1

3

I have solved my confusion by reading following two articles

and I summarized two reasons for why use 128 bytes(twice cacheline size) to pad

  • the cacheline size of most modern mainstream processors is 64 bytes or 128 bytes。If we padd around with 64 bytes, this will also cause false sharding in the processor which cacheline size is 128 bytes.

  • CPU Adjacent Sector Prefetch is a BIOS feature specific to the Intel processors,when this feature is enabled,the processor will fetch the cache line containing the currently requested data, and prefetch the following cache line, Prefetching can occupy two cache lines simultaneously,

as a result of those two reason we must redouble the padding size.

bin
  • 51
  • 6