Java 与 CPU 高速缓存

13
Java CPU ṛ᭛ᖨ ଢปԄ 2016.07.20

Transcript of Java 与 CPU 高速缓存

Page 1: Java 与 CPU 高速缓存

Java CPU 2016.07.20

Page 2: Java 与 CPU 高速缓存

Page 3: Java 与 CPU 高速缓存
Page 4: Java 与 CPU 高速缓存

• Direct Mapping

• N-way Mapping

• LRU

• RND

• write through

• write back

• CPU cache line

Page 5: Java 与 CPU 高速缓存

Mac Cache

• sudo sysctl -a | grep cache

Page 6: Java 与 CPU 高速缓存
Page 7: Java 与 CPU 高速缓存

Cache Coherence• MESI https://en.wikipedia.org/wiki/MESI_protocol

• write back

• Cache line: dirty valid

• Modified Cache

• Exclusive Cache

• Shared Cache

• Invalid

Page 8: Java 与 CPU 高速缓存

MESI

RFO: Request For Owner

Page 9: Java 与 CPU 高速缓存

MESI • http://blog.csdn.net/muxiqingyang/article/details/6615199

Page 10: Java 与 CPU 高速缓存

Java

• L1CacheMiss.java

• duration = 701358693

• duration = 10996917277

Page 11: Java 与 CPU 高速缓存

Java• False Sharing

Page 12: Java 与 CPU 高速缓存

False sharing

• Java 8:

• @sun.misc.Contended

• -XX:-RestrictContended

• FalseSharing.java

• duration = 27174444875

• duration = 3928016195

• duration = 3926949331

Page 13: Java 与 CPU 高速缓存

• https://en.wikipedia.org/wiki/CPU_cache

• http://blog.csdn.net/robertsong2004/article/details/38340247

• https://en.wikipedia.org/wiki/MESI_protocol

• http://blog.csdn.net/realxie/article/details/7317630

• http://mechanical-sympathy.blogspot.jp/2011/07/false-sharing.html

• http://coderplay.iteye.com/blog/1485760

• http://coderplay.iteye.com/blog/1486649

• http://psy-lob-saw.blogspot.jp/2013/05/know-thy-java-object-memory-layout.html