Hi Roland,

Regarding some of your suggestions, point 3 and point 10 are what I do, and
are related, because although in general I try to have almost nothing in
the host application (to enable live updates for as much of the product
scope as possible), as the host application has to be able to log startup
(just in case there's a failure when starting the framework), the logging
subsystem is (for me) part of the host.  I use SLF4J with logback, and
export it into the framework with FRAMEWORK_SYSTEMPACKAGES_EXTRA too
(specifically, I don't export logback, just SLF4J and the SLF4J wrappers
for Log4J and Commons Logging, as well as an implementation of the OSGi
logservice).  Furthermore, I implement the Felix logger by delegating onto
SLF4J too.

With point 4, I'm guessing you mean that you effectively build bundles by
extracting classes in wrapped libraries directly into your bundle, as
opposed to Bundle-Classpath?

With point 9, another watchout if you use background threads to start
stuff, especially if you hang on to a reference to the bundle context, is
to be sure that your code can handle the bundle context becoming invalid.
 This happens a lot when running unit tests with the framework, when
starting/stopping the framework fast and frequently.

--
Christopher



On 20 September 2013 18:45, Roland <[email protected]> wrote:

> Today I investigated the performance-effects of dynamic imports. Replacing
> the dynamic imports with static imports reduces the start time of my system
> by about ~10%. (it depends on how many imports you have)
>
> My summary...
> If someone asks me how to reduce the startup time, then I would suggest
> him:
>
> 1. *Reduce / avoid (transitive) dependencies at all.* (Choose thirdparty
> bundles with less transitive dependencies.) I achieved the biggest speed
> boost by far by downgrading of Log4j2 to Log4j1.2.
> 2. Embed all transitive dependencies together with the library you want to
> wrap.
> 3. Embed thirdparty bundles like log4j & Co. in the systembundle and export
> them with FRAMEWORK_SYSTEMPACKAGES_EXTRA.
> 4. Extract all classes of an embedded library into your wrapper bundle.
> (inline=true)
> 5. Avoid dynamic imports.
> 6. Declare unnecessary / "unused" package dependencies as optional.
> (resolution:=optional).
> 7. Use lazy activation.
> 8. Use hooks / threads in the BundleActivator-callbacks if you have to wait
> / synchronize.
> 9. Do not implement Declarative Services if you have to synchronize
> threads.
> (You have to wait until all DS are registered, but that can happen very
> late.)
> 10. Do not use the LogService, implement your own
> org.apache.felix.framework.Logger instead.
> 11. Do not clean the bundle cache before startup, *start only cached
> bundles*!
>
> Did I forget something?
>
> best regards
> Roland
>
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/How-to-improve-the-start-time-of-Apache-Felix-tp5004833p5005101.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to