OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author:...

29
OSGi Performance Bloopers | © 2009 Martin Lippert; made available under the EPL v1.0 OSGi Performance Bloopers Martin Lippert

Transcript of OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author:...

Page 1: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

OSGi Performance Bloopers | © 2009 Martin Lippert; made available under the EPL v1.0

OSGi Performance Bloopers

Martin Lippert

Page 2: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...
Page 3: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...
Page 4: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...
Page 5: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

What is this all about?

Page 6: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

„Take the fat man off your app and it will run faster“

Page 7: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Find out where the problem is...

failblog.com

Page 8: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

It‘s never where you expect it

failblog.com

Page 9: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Measure !!!

Page 10: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

In most cases your performance problems are not related to OSGi at all...

Insteadpoor database access

scalability of algorithmswrong usage of HashMaps

Strings...

Page 11: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

But now, lets focus on

OSGi

Page 12: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Startup

Page 13: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Proposal mock-up – not an actual program

A solution...?!?

from Chris Laffras talk on Eclipse performance

Page 14: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Don‘t turn on everything...!!!

Bundle activation can be expensive

Page 15: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Avoid bundle activationif possible

Use insteadextension registry

lazy activationno activation

Page 16: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Do work asynchronously

How?Lazy initializations

Threading (but complex)Extender pattern

Page 17: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Take care what others add

failblog.com

Extenders can cause „interesting“

behavior at startup

Page 18: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Example:Spring Dynamic Modules

Page 19: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Spring DM

creates application context (on bundle activation)sync or async

sounds good, eh?

Page 20: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

But...

XML parsing is expensiveproxy bean creation is expensivebean creation can be expensive

if you do this for hundreds on bundles, you will wait for a long time

Page 21: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Avoid bean + proxy creation

„lazy-init=true“

Page 22: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Lazy activation can also be dangerous

bundle is activatedspring context is created

class is loaded from another bundle

the provider bundle is now activated (lazy)runs itself activator

creates spring context

Page 23: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Don‘t clean too often

Page 24: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Equinox has the „-clean“ optionDon‘t use it!!!

It cleans all the OSGi framework caches at startup

Page 25: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

modules, abstractions, APIs

Page 26: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

sometimes results in calling the same method over and

over again

Page 27: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

Conclusions

Page 28: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

1. Measure2. Optimize

3. Goto 1.

Page 29: OSGi Performance Bloopers - martinlippert · 2009-11-11 · OSGi Performance Bloopers Author: Martin Lippert Created Date: 20091111160917Z ...

OSGi Performance Bloopers | © 2009 Martin Lippert; made available under the EPL v1.0

Thank you for your attention

Martin Lippert:[email protected]