SlideShare a Scribd company logo
Martin Lippert	

Principal Software Engineer - Pivotal	

mlippert@gopivotal.com	

@martinlippert

Optimizing	

Performance	

how to make your Eclipsebased tools run faster
Every developer benefits
from better performance
Find out where the problem is...

failblog.com
Measure !!!
VisualVM
!

Free	

Easy to use	

comes as part of the JDK	

extremely useful to capture data remotely
YourKit

used for comprehensive analysis	

various options and ways to track down issues	

$$$	

!
!

alternative:	


JProfiler
$$$
the case
trivial: expensive calls inside loops
findFilesForLocationURI(..) is slow

step 1: fix this in the Eclipse platform
findFilesForLocationURI(..) is slow

step 2: cache results if that makes sense
findFilesForLocationURI(..) is slow
step 3: if you can‘t avoid massive use of this,

optimize for the most likely case
Build workspace (16%)...

why is the build taking	

soooooo long... ???
Build workspace (16%)...
Build workspace (16%)...
taken from a different case

what is exactly going on under the hood?
Build workspace (16%)...
taken from a different case

what is exactly going on under the hood?
•

the Spring-specific builder: sloooooow...
Build workspace (16%)...
taken from a different case

what is exactly going on under the hood?
•

•

the Spring-specific builder: sloooooow...

the Maven project builder: slooooow...

•

the WTP JS builder: slooooow...
Build workspace (16%)...
taken from a different case

what is exactly going on under the hood?
•

•

the Spring-specific builder: sloooooow...

the Maven project builder: slooooow...

•

the WTP JS builder: slooooow...

•

the core implementation is ultra fast (compiling
Java, for example, but also reconciling, invoking
content assist, etc.)
But wait a moment...
But wait a moment...

what is this ?!?
Action 1: Configure your Eclipse wisely

max heap size

build workspace

-Xmx768m

30min

!

!

!

!

!

!

-Xmx1024m

~7min
Action 2: Reduce garbage
and memory usage in general

•
•
•

String.format creates a lot of garbage 	

called many many times 	

most of the time with exactly one argument
Action 2: Reduce garbage
and memory usage in general











public Set<IBean> getBeans() {

 Set<IBean> allBeans = new LinkedHashSet<IBean>(beans.values());

 for (IBeansImport beansImport : imports) {

 
 for (IBeansConfig bc : beansImport.getImportedBeansConfigs()) {

 
 
 allBeans.addAll(bc.getBeans());

 
 }

 }

 return Collections.unmodifiableSet(allBeans);
}
Action 2: Reduce garbage
and memory usage in general
new set with copied content











public Set<IBean> getBeans() {

 Set<IBean> allBeans = new LinkedHashSet<IBean>(beans.values());

 for (IBeansImport beansImport : imports) {

 
 for (IBeansConfig bc : beansImport.getImportedBeansConfigs()) {

 
 
 allBeans.addAll(bc.getBeans());

 
 }

 }

 return Collections.unmodifiableSet(allBeans);
}
recursive call

•
•

imagine this is called with deep recursion
but since the method looks quite innocent, it is called
many times while doing the build
Now back to the details of this…

•

the Spring-specific builder: sloooooow...
O(n)
matters for scalability
watch out for visitors


class ResourceDeltaVisitor implements IResourceDeltaVisitor {

















}

!

public boolean visit(IResourceDelta aDelta) throws CoreException {

IResource resource = aDelta.getResource();

if (resource instanceof IFile) {


checkResource(resource);

}

return true;
}
watch out for visitors


class ResourceDeltaVisitor implements IResourceDeltaVisitor {

















}

!

public boolean visit(IResourceDelta aDelta) throws CoreException {

IResource resource = aDelta.getResource();

if (resource instanceof IFile) {


checkResource(resource);

}

return true;
}

•
•
•

this might be called many many times	

take care to make this simple and fast	

not allowed to iterate over collections
watch out for visitors


class ResourceDeltaVisitor implements IResourceDeltaVisitor {

















}

!

•

public boolean visit(IResourceDelta aDelta) throws CoreException {

IResource resource = aDelta.getResource();

if (resource instanceof IFile) {


checkResource(resource);

}

return true;
}

•
•
•

this might be called many many times	

take care to make this simple and fast	

not allowed to iterate over collections

in our case:
• takes a look at individual IResource objects
• identify the defined types
• iterate over all defined beans and check for type
dependency
the case: type checks


Set<IType> typesToCheck = new HashSet<IType>();









IType[] types = cu.getAllTypes();
for (IType type : types) {

IType[] subTypes = type.newTypeHierarchy(monitor).getAllSubtypes(type);

if (subTypes != null && subTypes.length > 0) {


typesToCheck.addAll(Arrays.asList(subTypes));

}
}

!

!
!

loop over beans and check each bean type whether it is contained in
typesToCheck
the case: type checks


Set<IType> typesToCheck = new HashSet<IType>();









IType[] types = cu.getAllTypes();
for (IType type : types) {

IType[] subTypes = type.newTypeHierarchy(monitor).getAllSubtypes(type);

if (subTypes != null && subTypes.length > 0) {


typesToCheck.addAll(Arrays.asList(subTypes));

}
}

!

!
!

loop over beans and check each bean type whether it is contained in
typesToCheck

•
•
•

asking a type for its hierarchy is slow	

cached, but only for a limited number of hierarchies	

doing this for all resources of a build can take a very long time
instead:
we built our own type hierarchy engine
TypeHierarchyEngine
it reads bytecode (only type information)	

it walks up the super classes and interfaces	

it caches already loaded type information
instead:
we built our own type hierarchy engine
TypeHierarchyEngine
it reads bytecode (only type information)	

it walks up the super classes and interfaces	

it caches already loaded type information
Lessons Learned
reading bytecode is super super fast	

finding the bytecode on the classpath is super slow
What is designed to be fast?

Reconciling

Be extremely careful when implementing a
reconcile participant	

!

Content-Assist

Has to be fast	

Don‘t do anything if its not your job	

!

...
Startup time is important

(even if you start Eclipse just once a day)	

!
!

Don‘t start

all your bundles and do stuff at startup	

!

Do caching

(Equinox Weaving, for example)	

!

Uninstall bundles

to get rid of things you don‘t need
A different approach
Proposal mock-up – not an actual program

from Chris Laffras talk on Eclipse performance
1.Measure
2.Optimize
!

3.Goto 1.
Q&A
!
and thank you for your attention

Martin Lippert	

Principal Software Engineer - Pivotal	

mlippert@gopivotal.com	

@martinlippert

More Related Content

PDF
Google Guava & EMF @ GTUG Nantes
PDF
Elixir: the not-so-hidden path to Erlang
PDF
Google guava
PDF
知っておきたいSpring Batch Tips
DOCX
MVest Spring Job Execution
PDF
Beautiful code
PDF
Google Guava
PDF
Google Guava for cleaner code
Google Guava & EMF @ GTUG Nantes
Elixir: the not-so-hidden path to Erlang
Google guava
知っておきたいSpring Batch Tips
MVest Spring Job Execution
Beautiful code
Google Guava
Google Guava for cleaner code

What's hot (10)

PPTX
AssertJ quick introduction
PDF
Scala, just a better java?
PDF
Stuff you didn't know about action script
PDF
Programming JVM Bytecode with Jitescript
PDF
The core libraries you always wanted - Google Guava
PDF
Programming JVM Bytecode
PDF
Scala101, first steps with Scala
PDF
Google guava - almost everything you need to know
PDF
JDD 2016 - Grzegorz Piwowarek - Davaslang - Functional Java Done Right
PPTX
Javascript Testing with Jasmine 101
AssertJ quick introduction
Scala, just a better java?
Stuff you didn't know about action script
Programming JVM Bytecode with Jitescript
The core libraries you always wanted - Google Guava
Programming JVM Bytecode
Scala101, first steps with Scala
Google guava - almost everything you need to know
JDD 2016 - Grzegorz Piwowarek - Davaslang - Functional Java Done Right
Javascript Testing with Jasmine 101
Ad

Viewers also liked (10)

PDF
Home- (office) ?
PDF
JAX 2013: Modern Architectures with Spring and JavaScript
PDF
JAX 2013: Introducing Eclipse Orion
PDF
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
PDF
Modern Architectures with Spring and JavaScript
PDF
Scripted - Embracing Eclipse Orion
PDF
Spring Tooling: What's new and what's coming
PDF
WJAX 2013: Java8-Tooling in Eclipse
PDF
EclipseCon-Europe 2013: Making the Eclipse IDE fun again
PDF
WJAX 2013: Die PaaS-Parade - Teil 2 - Cloud Foundry
Home- (office) ?
JAX 2013: Modern Architectures with Spring and JavaScript
JAX 2013: Introducing Eclipse Orion
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
Modern Architectures with Spring and JavaScript
Scripted - Embracing Eclipse Orion
Spring Tooling: What's new and what's coming
WJAX 2013: Java8-Tooling in Eclipse
EclipseCon-Europe 2013: Making the Eclipse IDE fun again
WJAX 2013: Die PaaS-Parade - Teil 2 - Cloud Foundry
Ad

Similar to EclipseCon-Europe 2013: Optimizing performance - how to make your Eclipse-based tools run fasterEce2013 optimizing performance (20)

PPT
Java beans
PDF
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
PPT
Introduction to java beans
PDF
WebObjects Optimization
PDF
Java collections the force awakens
PDF
Naked Performance With Clojure
PDF
Pitfalls of Object Oriented Programming by SONY
PPTX
Repository performance tuning
KEY
Everything I Ever Learned About JVM Performance Tuning @Twitter
PDF
Java performance
PPTX
Spring MVC framework
PPTX
Skillwise - Enhancing dotnet app
PDF
Xtext beyond the defaults - how to tackle performance problems
PDF
5 Coding Hacks to Reduce GC Overhead
PPTX
DIY Java Profiler
PPTX
"Эффективность и оптимизация кода в Java 8" Сергей Моренец
PDF
Pitfalls of Object Oriented Programming
PDF
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
PDF
Scala in practice - 3 years later
PDF
130614 sebastiano panichella - mining source code descriptions from develo...
Java beans
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
Introduction to java beans
WebObjects Optimization
Java collections the force awakens
Naked Performance With Clojure
Pitfalls of Object Oriented Programming by SONY
Repository performance tuning
Everything I Ever Learned About JVM Performance Tuning @Twitter
Java performance
Spring MVC framework
Skillwise - Enhancing dotnet app
Xtext beyond the defaults - how to tackle performance problems
5 Coding Hacks to Reduce GC Overhead
DIY Java Profiler
"Эффективность и оптимизация кода в Java 8" Сергей Моренец
Pitfalls of Object Oriented Programming
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
Scala in practice - 3 years later
130614 sebastiano panichella - mining source code descriptions from develo...

More from martinlippert (12)

PDF
PaaS Parade - Cloud Foundry
PDF
Browser and Cloud - The Future of IDEs?
PDF
Modern Architectures with Spring and JavaScript
PDF
What's new with tooling for Spring, Grails, and the Cloud
PDF
Tooling for the JavaScript Era
PDF
Embracing Eclipse Orion
PDF
Why SOLID matters - even for JavaScript
PDF
JAX 2012: Moderne Architektur mit Spring und JavaScript
PDF
JAX 2012: Pimp Your IDE Productivity
PDF
WaveMaker - Spring Roo - SpringSource Tool Suite - Choosing the right tool fo...
PDF
Spring Tooling Update - New & Noteworty (at SpringOne 2011)
PDF
Classloading and Type Visibility in OSGi
PaaS Parade - Cloud Foundry
Browser and Cloud - The Future of IDEs?
Modern Architectures with Spring and JavaScript
What's new with tooling for Spring, Grails, and the Cloud
Tooling for the JavaScript Era
Embracing Eclipse Orion
Why SOLID matters - even for JavaScript
JAX 2012: Moderne Architektur mit Spring und JavaScript
JAX 2012: Pimp Your IDE Productivity
WaveMaker - Spring Roo - SpringSource Tool Suite - Choosing the right tool fo...
Spring Tooling Update - New & Noteworty (at SpringOne 2011)
Classloading and Type Visibility in OSGi

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
cuic standard and advanced reporting.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
sap open course for s4hana steps from ECC to s4
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
MYSQL Presentation for SQL database connectivity
cuic standard and advanced reporting.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.

EclipseCon-Europe 2013: Optimizing performance - how to make your Eclipse-based tools run fasterEce2013 optimizing performance

  • 1. Martin Lippert Principal Software Engineer - Pivotal mlippert@gopivotal.com @martinlippert Optimizing Performance how to make your Eclipsebased tools run faster
  • 2. Every developer benefits from better performance
  • 3. Find out where the problem is... failblog.com
  • 5. VisualVM ! Free Easy to use comes as part of the JDK extremely useful to capture data remotely
  • 6. YourKit used for comprehensive analysis various options and ways to track down issues $$$ ! ! alternative: JProfiler $$$
  • 9. findFilesForLocationURI(..) is slow step 1: fix this in the Eclipse platform
  • 10. findFilesForLocationURI(..) is slow step 2: cache results if that makes sense
  • 11. findFilesForLocationURI(..) is slow step 3: if you can‘t avoid massive use of this,
 optimize for the most likely case
  • 12. Build workspace (16%)... why is the build taking soooooo long... ???
  • 14. Build workspace (16%)... taken from a different case what is exactly going on under the hood?
  • 15. Build workspace (16%)... taken from a different case what is exactly going on under the hood? • the Spring-specific builder: sloooooow...
  • 16. Build workspace (16%)... taken from a different case what is exactly going on under the hood? • • the Spring-specific builder: sloooooow... the Maven project builder: slooooow... • the WTP JS builder: slooooow...
  • 17. Build workspace (16%)... taken from a different case what is exactly going on under the hood? • • the Spring-specific builder: sloooooow... the Maven project builder: slooooow... • the WTP JS builder: slooooow... • the core implementation is ultra fast (compiling Java, for example, but also reconciling, invoking content assist, etc.)
  • 18. But wait a moment...
  • 19. But wait a moment... what is this ?!?
  • 20. Action 1: Configure your Eclipse wisely max heap size build workspace -Xmx768m 30min ! ! ! ! ! ! -Xmx1024m ~7min
  • 21. Action 2: Reduce garbage and memory usage in general • • • String.format creates a lot of garbage called many many times most of the time with exactly one argument
  • 22. Action 2: Reduce garbage and memory usage in general public Set<IBean> getBeans() { Set<IBean> allBeans = new LinkedHashSet<IBean>(beans.values()); for (IBeansImport beansImport : imports) { for (IBeansConfig bc : beansImport.getImportedBeansConfigs()) { allBeans.addAll(bc.getBeans()); } } return Collections.unmodifiableSet(allBeans); }
  • 23. Action 2: Reduce garbage and memory usage in general new set with copied content public Set<IBean> getBeans() { Set<IBean> allBeans = new LinkedHashSet<IBean>(beans.values()); for (IBeansImport beansImport : imports) { for (IBeansConfig bc : beansImport.getImportedBeansConfigs()) { allBeans.addAll(bc.getBeans()); } } return Collections.unmodifiableSet(allBeans); } recursive call • • imagine this is called with deep recursion but since the method looks quite innocent, it is called many times while doing the build
  • 24. Now back to the details of this… • the Spring-specific builder: sloooooow...
  • 26. watch out for visitors class ResourceDeltaVisitor implements IResourceDeltaVisitor { } ! public boolean visit(IResourceDelta aDelta) throws CoreException { IResource resource = aDelta.getResource(); if (resource instanceof IFile) { checkResource(resource); } return true; }
  • 27. watch out for visitors class ResourceDeltaVisitor implements IResourceDeltaVisitor { } ! public boolean visit(IResourceDelta aDelta) throws CoreException { IResource resource = aDelta.getResource(); if (resource instanceof IFile) { checkResource(resource); } return true; } • • • this might be called many many times take care to make this simple and fast not allowed to iterate over collections
  • 28. watch out for visitors class ResourceDeltaVisitor implements IResourceDeltaVisitor { } ! • public boolean visit(IResourceDelta aDelta) throws CoreException { IResource resource = aDelta.getResource(); if (resource instanceof IFile) { checkResource(resource); } return true; } • • • this might be called many many times take care to make this simple and fast not allowed to iterate over collections in our case: • takes a look at individual IResource objects • identify the defined types • iterate over all defined beans and check for type dependency
  • 29. the case: type checks Set<IType> typesToCheck = new HashSet<IType>(); IType[] types = cu.getAllTypes(); for (IType type : types) { IType[] subTypes = type.newTypeHierarchy(monitor).getAllSubtypes(type); if (subTypes != null && subTypes.length > 0) { typesToCheck.addAll(Arrays.asList(subTypes)); } } ! ! ! loop over beans and check each bean type whether it is contained in typesToCheck
  • 30. the case: type checks Set<IType> typesToCheck = new HashSet<IType>(); IType[] types = cu.getAllTypes(); for (IType type : types) { IType[] subTypes = type.newTypeHierarchy(monitor).getAllSubtypes(type); if (subTypes != null && subTypes.length > 0) { typesToCheck.addAll(Arrays.asList(subTypes)); } } ! ! ! loop over beans and check each bean type whether it is contained in typesToCheck • • • asking a type for its hierarchy is slow cached, but only for a limited number of hierarchies doing this for all resources of a build can take a very long time
  • 31. instead: we built our own type hierarchy engine TypeHierarchyEngine it reads bytecode (only type information) it walks up the super classes and interfaces it caches already loaded type information
  • 32. instead: we built our own type hierarchy engine TypeHierarchyEngine it reads bytecode (only type information) it walks up the super classes and interfaces it caches already loaded type information Lessons Learned reading bytecode is super super fast finding the bytecode on the classpath is super slow
  • 33. What is designed to be fast? Reconciling Be extremely careful when implementing a reconcile participant ! Content-Assist Has to be fast Don‘t do anything if its not your job ! ...
  • 34. Startup time is important (even if you start Eclipse just once a day) ! ! Don‘t start all your bundles and do stuff at startup ! Do caching (Equinox Weaving, for example) ! Uninstall bundles to get rid of things you don‘t need
  • 35. A different approach Proposal mock-up – not an actual program from Chris Laffras talk on Eclipse performance
  • 37. Q&A ! and thank you for your attention Martin Lippert Principal Software Engineer - Pivotal mlippert@gopivotal.com @martinlippert