admin@glassfish.java.net

threading the LifecycleModuleService (test timings)

From: Lloyd L Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Tue, 16 Jan 2007 17:40:07 -0800

Tested with Apple Mac OS X 10.4.8 on a MacBook Pro Core 2 Duo 2.33GHz.

This comparison involves a modification to
com.sun.appserv.server.LifecycleModuleService. Individual Lifecycle
modules still run in a serialized fashion; this approach threads the
onInitialization(), onStartup() and onReady() methods of the
LifecycleModuleService.

Further gains would be possible by invoking individual modules in
their own threads, but due to the load order constraint imposed, this
could easily violate correctness. However, any N modules with an
identical load order could be initialized concurrently in 2 or more
threads.

...

Mac OS X CHUD developer tools allow disabling all cores but one. So
I disabled one core for the single core tests. This is ideal;
everything else on the system remains identical.

RESULTS

Numbers are in milliseconds, average of 3 runs.

dual core single-threaded: 11585
single core single-threaded: 12577

dual core multi-threaded: 10758
single core multi-threaded: 12630

CONCLUSIONS

1) The single-threaded version takes 7.6% longer to start (827ms
longer).

2) The multi-threaded version entails a 0.4% hit on a single core
machine.

The codes uses a "submit type" parameter (SYNC or ASYNC) when the
tasks are run, so if a boolean was available indicating single vs
multi-core, the code could trivially choose to use the non-threaded
version if only a single core were available.

3) The single-threaded nature of GlassFish startup is readily
evident; dual cores are very poorly utilized.

Lloyd