disruptor depth analysis

Learn disruptor, first to understand the following knowledge

Let's learn about CPU cache: http://ifeve.com/from-javaeye-cpu-cache/ , such as CPU cache hierarchical structure, such as a cache line concept, I know the students can skip.

 False sharing problem   http://ifeve.com/falsesharing   in Java programs, members of the array in the cache is continuous. In fact, member variables will be loaded from neighboring Java objects to the same cache line. If multiple threads operating different members of variables, but the same cache line, false sharing (False sharing) problem occurred

We know that a 64 byte cache line, and a Java program stationary object header 8 bytes (32-bit) or 12 bytes (64-bit compression system enabled by default, not open compressed into 16 bytes), as detailed in  the link we just need to fill six useless long integer make up 6 * 8 = 48 bytes, so that different VolatileLong objects in different cache lines, you can avoid false sharing a 64-byte (64-bit more than the cache line system it does not matter, as long as different threads do not operate the same cache line can be). this approach is called filled (Padding).

How to avoid false sharing, a magical cache line fill   http://ifeve.com/disruptor-cacheline-padding/

 

 

 

 

 

 

 

 

 

 

 

 

http://ifeve.com/false-sharing/

Guess you like

Origin www.cnblogs.com/amberJava/p/12654886.html