Your SlideShare is downloading. ×
What your jvm can do for you
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

What your jvm can do for you

635
views

Published on

Ask not what you can do for your JVM, ask what your JVM can do for you. …

Ask not what you can do for your JVM, ask what your JVM can do for you.
Ett långsamt mellanlager eller har vi någon nytta av den sett till prestanda?

Published in: Technology, News & Politics

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
635
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ask not what you can do foryour JVM, ask what your JVM can do for you Ett långsamt mellanlager eller har vi någon nytta av den sett till prestanda? Mattias Isegran Bergander
  • 2. Hur kom denna hit nu då...
  • 3. Och den här?!
  • 4. Det u ppenbara svaret...Kommer ni ihåg Java 1.0/1.1?Jämför med nu...(förutom att datorerna är snabbare)
  • 5. Historik1995: Java 1.01996: Java 1.11998: Java 1.22000: Java 1.32002: Java 1.42004: Java 1.52006: Java 1.6.........2011: Java 1.7
  • 6. Historik: Prestanda1995: Java 1.01996: Java 1.1 Symantec JIT1998: Java 1.2 Generational GC1999: Hotspot2000: Java 1.3 Hotspot default, Math, BigInteger2002: Java 1.42003: Java 1.4.2 Prestanda, ännu fler GC, SSE, SSE2, ...2004: Java 1.5 Class data sharing, GC ergonomics2006: Java 1.6 Biased locking, lock coarsening, adaptivespinning, arraycopy, SSE4.2, large page heap
  • 7. Historik: Prestanda2006: Java 1.62007: u4: Hotspot får separat version, 10.02008: u10: Plugin2, GUI prestanda, kernel installer2009: u14: Hotspot 14, 1:a escape analysis, compressed object pointers, experimental G12009: u1x: Hotspot 15, SSE 4.2 string intrinsics2010 : u18: Hotspot 16,2010: u21: Hotspot 17,2011: u23: Hotspot 19, Escape analysis default enabled2011: u25: Hotspot 202011: u30:2011: Java 1.7 Hotspot 212011: u2: Hotspot 22
  • 8. Förbättringar genom åren 1.2 1.3 1.4
  • 9. Förbättringar genom åren 1.2 1.3 1.4
  • 10. Förbättringar genom åren 1.4.2
  • 11. Förbättringar genom åren 1.5
  • 12. Förbättringar genom åren 1.5
  • 13. Förbättringar genom åren 1.6
  • 14. Förbättringar genom åren 1.5 1.6 1.7http://geeknizer.com/java-7-whats-new-performance-benchmark-1-5-1-6-1-7/
  • 15. Det längre svaret... Några uppenbara: ● GC i separat(a) tråd(ar) ● JIT kompilering i bakgrunden ● Bättre utnyttjande av CPU, i386, i586, Core2, ..., 32/64bit, SSE/1/2/4.2 ○ Ny JVM => bättre prestanda gratis utan omkompilering ● Fler intrinsics
  • 16. Det längre svaret...Bättre analys ger tex: ● Null check elimination, VM behöver göra: if (object == null) throw new NullPointerException() ● Array bounds check elimination 0>=i && i < array.length ● Hoist duplicates & repeated use int length = array.length; for (int i=0;i<array.length;i++) { if (array.length ...) {
  • 17. Det längre svaret...VM-lager inte bara nackdelar i prestanda: ● Pointers make optimizations hard x = y + 2 * (...) *p = ... arr[j] = ... z = x + ... ● Garbage Collection -> memory locality ● Runtime optimeringar ○ CPU, P4, Sandy Bridge, SSE, cache sizes, cores, ... ○ Current class hierarchy and inlining ○ Branch predications
  • 18. Det längre svaret...Fler: ● Generational Garbage Collector ● Inlining ● Spekulativa optimeringar ● Förbättrade Garbage Collectors ○ Senaste: G1, "Garbage First" ● Tiered compilation (vs client/server) ● Locks: ○ Lock elision ○ Lock coarsining ○ Adaptive locking ○ Biased locks ● NUMA aware ● Large pages (Solaris, Linux) ● ...
  • 19. Det längre svaret...Några intressanta● Virtual method inlining● Escape Analysis (java 6u14, default enabled java7)
  • 20. Så vad har vi nu då?Programspråket Java hör till kategorin "desnabba språken", tillsammans med Fortranoch C/C++~50-100% av C/C++ prestanda Ibland snabbare! Quake2 vs Jake2 (Java5)Men går utan problem att hitta falldär C++ är snabbare...
  • 21. Escape AnalysisTex Dimension, Point, get/set, men inte begränsat till det...http://weblogs.java.net/blog/forax/archive/2009/10/06/jdk7-do-escape-analysis-default
  • 22. Escape Analysis
  • 23. Escape AnalysisOff: ~430ms On: ~110ms
  • 24. Generational and Copying GCAllokera en större bit Heap i förväg Effektivisera per tråd med trådlokalt minne så ingen contention...
  • 25. Generational and Copying GCGenerational: ● Young, Old (and Perm)Young ● De flesta objekt är kortlivade, 92-98% ● Bevara (kopiera) bara de levande!Minne:
  • 26. Generational and Copying GC Young
  • 27. Generational and Copying GC Young
  • 28. Speculative virtual method inlining
  • 29. Speculative virtual method inlining
  • 30. Speculative virtual method inlining
  • 31. February 2, 2004Bill Venners: When I asked you earlier (In Part IV) about why non-virtual methods are thedefault in C#, one of your reasons was performance. You said:We can observe that as people write code in Java, they forget to mark their methods final.Therefore, those methods are virtual. Because theyre virtual, they dont perform as well.Theres just performance overhead associated with being a virtual method.Another thing that happens in the adaptive optimizing JVMs is theyll inline virtual methodinvocations, because a lot of times only one or two implementations are actually being used.Anders Hejlsberg:They can never inline a virtual method invocation.http://www.artima.com/intv/choices.html
  • 32. Framtiden● Tiered compilation default?● Disruptor pattern● Azul ZingVM -Cliff Click ○ Scalability ○ 512GB heap ○ Pauseless Garbage Collection● Java 8 ○ Hotspot <-> JRockit ○ Mer multicore i VM och API (ForkJoin med lambda tex)● Java 9 ○ Self-tuning JVM ○ Hypervisor integration ○ Tail calls, continuations ○ "Massive multicore scalability"
  • 33. References & Further readinghttp://java.sun.com/j2se/1.4.2/performance.guide.htmlhttp://java.sun.com/j2se/1.4.2/1.4.2_whitepaper.htmlhttp://java.sun.com/performance/reference/whitepapers/5.0_performance.htmlhttp://java.sun.com/performance/reference/whitepapers/6_performance.htmlhttp://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance-enhancements-7.htmlhttp://www.ibm.com/developerworks/java/library/j-jtp09275/index.htmlhttp://www.ibm.com/developerworks/java/library/j-jtp10185/http://www.ibm.com/developerworks/java/library/j-jtp12214/index.htmlhttp://scribblethink.org/Computer/javaCbenchmark.html
  • 34. Tack Mattias Isegran Bergander Feedback? mattias.bergander@gmail.comprofile.google.com/mattias.bergander twitter.com/mbergander mattiaslife.blogspot.com