SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
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?




         Mattias Isegran Bergander
Hur kom denna hit nu då...
Och den här?!
Det u ppenbara svaret...

Kommer ni ihåg Java 1.0/1.1?


Jämför med nu...

(förutom att datorerna är snabbare)
Historik

1995: Java 1.0
1996: Java 1.1
1998: Java 1.2
2000: Java 1.3
2002: Java 1.4
2004: Java 1.5
2006: Java 1.6
...
...
...
2011: Java 1.7
Historik: Prestanda

1995: Java 1.0
1996: Java 1.1 Symantec JIT
1998: Java 1.2 Generational GC
1999: Hotspot
2000: Java 1.3 Hotspot default, Math, BigInteger
2002: Java 1.4
2003: Java 1.4.2 Prestanda, ännu fler GC, SSE, SSE2, ...
2004: Java 1.5 Class data sharing, GC ergonomics
2006: Java 1.6 Biased locking, lock coarsening, adaptive
spinning, arraycopy, SSE4.2, large page heap
Historik: Prestanda

2006: Java 1.6
2007: u4: Hotspot får separat version, 10.0
2008: u10: Plugin2, GUI prestanda, kernel installer
2009: u14: Hotspot 14, 1:a escape analysis,
         compressed object pointers, experimental G1
2009: u1x: Hotspot 15, SSE 4.2 string intrinsics
2010 : u18: Hotspot 16,
2010: u21: Hotspot 17,
2011: u23: Hotspot 19, Escape analysis default enabled
2011: u25: Hotspot 20
2011: u30:
2011: Java 1.7 Hotspot 21
2011: u2: Hotspot 22
Förbättringar genom åren 1.2 1.3 1.4
Förbättringar genom åren 1.2 1.3 1.4
Förbättringar genom åren 1.4.2
Förbättringar genom åren 1.5
Förbättringar genom åren 1.5
Förbättringar genom åren 1.6
Förbättringar genom åren 1.5 1.6 1.7




http://geeknizer.com/java-7-whats-new-performance-benchmark-1-5-1-6-1-7/
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
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 ...) {
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
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)
 ● ...
Det längre svaret...

Några intressanta

● Virtual method inlining

● Escape Analysis (java 6u14, default enabled java7)
Så vad har vi nu då?
Programspråket Java hör till kategorin "de
snabba språken", tillsammans med Fortran
och C/C++
~50-100% av C/C++ prestanda
              Ibland snabbare!
                Quake2 vs Jake2 (Java5)


Men går utan problem att hitta fall
där C++ är snabbare...
Escape Analysis
Tex 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
Escape Analysis
Escape Analysis
Off: ~430ms



                  On: ~110ms
Generational and Copying GC

Allokera en större bit Heap i förväg




                      Effektivisera per tråd med trådlokalt
                      minne så ingen contention...
Generational and Copying GC
Generational:
 ● Young, Old (and Perm)


Young
 ● De flesta objekt är kortlivade, 92-98%
 ● Bevara (kopiera) bara de levande!

Minne:
Generational and Copying GC
 Young
Generational and Copying GC
 Young
Speculative virtual method inlining
Speculative virtual method inlining
Speculative virtual method inlining
February 2, 2004

Bill Venners: When I asked you earlier (In Part IV) about why non-virtual methods are the
default 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 they're virtual, they don't perform as well.
There's just performance overhead associated with being a virtual method.

Another thing that happens in the adaptive optimizing JVMs is they'll inline virtual method
invocations, 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
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"
References & Further reading


http://java.sun.com/j2se/1.4.2/performance.guide.html
http://java.sun.com/j2se/1.4.2/1.4.2_whitepaper.html
http://java.sun.com/performance/reference/whitepapers/5.0_performance.html
http://java.sun.com/performance/reference/whitepapers/6_performance.html
http://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance-
enhancements-7.html

http://www.ibm.com/developerworks/java/library/j-jtp09275/index.html
http://www.ibm.com/developerworks/java/library/j-jtp10185/
http://www.ibm.com/developerworks/java/library/j-jtp12214/index.html

http://scribblethink.org/Computer/javaCbenchmark.html
Tack

     Mattias Isegran Bergander

               Feedback?
   mattias.bergander@gmail.com
profile.google.com/mattias.bergander
        twitter.com/mbergander
        mattiaslife.blogspot.com

Weitere ähnliche Inhalte

Was ist angesagt?

"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
Vladimir Ivanov
 
Choosing the right parallel compute architecture
Choosing the right parallel compute architecture Choosing the right parallel compute architecture
Choosing the right parallel compute architecture
corehard_by
 
Dalvik Vm &amp; Jit
Dalvik Vm &amp; JitDalvik Vm &amp; Jit
Dalvik Vm &amp; Jit
Ankit Somani
 

Was ist angesagt? (20)

Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & Profiling
 
Multithreading in Node.js and JavaScript
Multithreading in Node.js and JavaScriptMultithreading in Node.js and JavaScript
Multithreading in Node.js and JavaScript
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
Choosing the right parallel compute architecture
Choosing the right parallel compute architecture Choosing the right parallel compute architecture
Choosing the right parallel compute architecture
 
Using Flame Graphs
Using Flame GraphsUsing Flame Graphs
Using Flame Graphs
 
Threading in java - a pragmatic primer
Threading in java - a pragmatic primerThreading in java - a pragmatic primer
Threading in java - a pragmatic primer
 
Inside the JVM
Inside the JVMInside the JVM
Inside the JVM
 
Dalvik Vm &amp; Jit
Dalvik Vm &amp; JitDalvik Vm &amp; Jit
Dalvik Vm &amp; Jit
 
JDK not so hidden treasures
JDK not so hidden treasuresJDK not so hidden treasures
JDK not so hidden treasures
 
STM
STMSTM
STM
 
Profiling deep learning network using NVIDIA nsight systems
Profiling deep learning network using NVIDIA nsight systemsProfiling deep learning network using NVIDIA nsight systems
Profiling deep learning network using NVIDIA nsight systems
 
JVM: A Platform for Multiple Languages
JVM: A Platform for Multiple LanguagesJVM: A Platform for Multiple Languages
JVM: A Platform for Multiple Languages
 
Jvm performance tuning
Jvm performance tuningJvm performance tuning
Jvm performance tuning
 
Python + GDB = Javaデバッガ
Python + GDB = JavaデバッガPython + GDB = Javaデバッガ
Python + GDB = Javaデバッガ
 
Lock free programming - pro tips devoxx uk
Lock free programming - pro tips devoxx ukLock free programming - pro tips devoxx uk
Lock free programming - pro tips devoxx uk
 
Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
 
JavaOne summary
JavaOne summaryJavaOne summary
JavaOne summary
 

Andere mochten auch (7)

2014 fifa wc_fixture_in_pakistan_time
2014 fifa wc_fixture_in_pakistan_time2014 fifa wc_fixture_in_pakistan_time
2014 fifa wc_fixture_in_pakistan_time
 
The Concept of Cycle in Modern Science, Astrology and I Ching. Charles M. Gra...
The Concept of Cycle in Modern Science, Astrology and I Ching. Charles M. Gra...The Concept of Cycle in Modern Science, Astrology and I Ching. Charles M. Gra...
The Concept of Cycle in Modern Science, Astrology and I Ching. Charles M. Gra...
 
english softskill
english softskillenglish softskill
english softskill
 
I Thing New Yorker Jan1972
I  Thing  New Yorker  Jan1972I  Thing  New Yorker  Jan1972
I Thing New Yorker Jan1972
 
Wikis
WikisWikis
Wikis
 
14.05.2012 Opening the tool box: Development, testing and deployment in the H...
14.05.2012 Opening the tool box: Development, testing and deployment in the H...14.05.2012 Opening the tool box: Development, testing and deployment in the H...
14.05.2012 Opening the tool box: Development, testing and deployment in the H...
 
10 mobile gaming trends (2010)
10 mobile gaming trends (2010)10 mobile gaming trends (2010)
10 mobile gaming trends (2010)
 

Ähnlich wie What your jvm can do for you

Ähnlich wie What your jvm can do for you (20)

JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky Problem
 
Java gpu computing
Java gpu computingJava gpu computing
Java gpu computing
 
Java Memory Model
Java Memory ModelJava Memory Model
Java Memory Model
 
Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java code
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
 
Jvm profiling under the hood
Jvm profiling under the hoodJvm profiling under the hood
Jvm profiling under the hood
 
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Surge2012
Surge2012Surge2012
Surge2012
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
 
How I Sped up Complex Matrix-Vector Multiplication: Finding Intel MKL's "S
How I Sped up Complex Matrix-Vector Multiplication: Finding Intel MKL's "SHow I Sped up Complex Matrix-Vector Multiplication: Finding Intel MKL's "S
How I Sped up Complex Matrix-Vector Multiplication: Finding Intel MKL's "S
 
Programar para GPUs
Programar para GPUsProgramar para GPUs
Programar para GPUs
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Java vs. C/C++
Java vs. C/C++Java vs. C/C++
Java vs. C/C++
 
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
 
Profiling & Testing with Spark
Profiling & Testing with SparkProfiling & Testing with Spark
Profiling & Testing with Spark
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

What your jvm can do for you

  • 1. 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? Mattias Isegran Bergander
  • 2. Hur kom denna hit nu då...
  • 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. Historik 1995: Java 1.0 1996: Java 1.1 1998: Java 1.2 2000: Java 1.3 2002: Java 1.4 2004: Java 1.5 2006: Java 1.6 ... ... ... 2011: Java 1.7
  • 6. Historik: Prestanda 1995: Java 1.0 1996: Java 1.1 Symantec JIT 1998: Java 1.2 Generational GC 1999: Hotspot 2000: Java 1.3 Hotspot default, Math, BigInteger 2002: Java 1.4 2003: Java 1.4.2 Prestanda, ännu fler GC, SSE, SSE2, ... 2004: Java 1.5 Class data sharing, GC ergonomics 2006: Java 1.6 Biased locking, lock coarsening, adaptive spinning, arraycopy, SSE4.2, large page heap
  • 7. Historik: Prestanda 2006: Java 1.6 2007: u4: Hotspot får separat version, 10.0 2008: u10: Plugin2, GUI prestanda, kernel installer 2009: u14: Hotspot 14, 1:a escape analysis, compressed object pointers, experimental G1 2009: u1x: Hotspot 15, SSE 4.2 string intrinsics 2010 : u18: Hotspot 16, 2010: u21: Hotspot 17, 2011: u23: Hotspot 19, Escape analysis default enabled 2011: u25: Hotspot 20 2011: u30: 2011: Java 1.7 Hotspot 21 2011: u2: Hotspot 22
  • 14. Förbättringar genom åren 1.5 1.6 1.7 http://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 "de snabba språken", tillsammans med Fortran och C/C++ ~50-100% av C/C++ prestanda Ibland snabbare! Quake2 vs Jake2 (Java5) Men går utan problem att hitta fall där C++ är snabbare...
  • 21. Escape Analysis Tex 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
  • 24. Generational and Copying GC Allokera en större bit Heap i förväg Effektivisera per tråd med trådlokalt minne så ingen contention...
  • 25. Generational and Copying GC Generational: ● Young, Old (and Perm) Young ● De flesta objekt är kortlivade, 92-98% ● Bevara (kopiera) bara de levande! Minne:
  • 31. February 2, 2004 Bill Venners: When I asked you earlier (In Part IV) about why non-virtual methods are the default 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 they're virtual, they don't perform as well. There's just performance overhead associated with being a virtual method. Another thing that happens in the adaptive optimizing JVMs is they'll inline virtual method invocations, 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 reading http://java.sun.com/j2se/1.4.2/performance.guide.html http://java.sun.com/j2se/1.4.2/1.4.2_whitepaper.html http://java.sun.com/performance/reference/whitepapers/5.0_performance.html http://java.sun.com/performance/reference/whitepapers/6_performance.html http://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance- enhancements-7.html http://www.ibm.com/developerworks/java/library/j-jtp09275/index.html http://www.ibm.com/developerworks/java/library/j-jtp10185/ http://www.ibm.com/developerworks/java/library/j-jtp12214/index.html http://scribblethink.org/Computer/javaCbenchmark.html
  • 34. Tack Mattias Isegran Bergander Feedback? mattias.bergander@gmail.com profile.google.com/mattias.bergander twitter.com/mbergander mattiaslife.blogspot.com