Troubleshooting
Problem
This article provides an overview of using Jandex with IBM WebSphere Application Server, Liberty Profile. When Jandex indexes are suitably placed in application archives, and Liberty is enabled to read these indexes, Liberty will obtain class and annotations metadata from the indexes instead of performing expensive iterative scans of application classes. This can result in up to a 40% reduction to application startup times.
Symptom
Application startup time can have a large component which is time spent scanning application classes.
Startup of JavaEE applications requires scans of application classes.? The scans record three basic categories of information: Basic class definition information; Class relationship information; And, Annotations information.? The scans are of all application classes, with a consequence that the more classes an application has, the longer the time spent scanning the classes.? When an application has a large number of classes (generally, 10,000 or more), the time spent scanning the classes becomes a significant proportion of application startup time.
Cause
Class and annotation scanning, which is required by JavaEE including CDI, is expensive.
Class scanning is a requirement of JavaEE, and is performed for three primary purposes:
- To generate complete module metadata.
- To discover servlet container initializers of web modules.
- To perform bean discovery for CDI archives.
- Scanning is comprehensive: Scanning iterates across all classes of an application.
- Scanning is IO intensive: Scanning must perform a basic read of the data for each class of an application.
- Scanning is processing intensive: Scanning must interpret basic data read from a class resource as java class information.
Environment
The proportion of startup time spent scanning classes does not depend on environment features.? The proportion of startup time spent scanning classes does depend on application features.
The time spent scanning classes has no significant differences in different environments.
Time spent scanning classes does depend on the features which are in use by the application which is being started.
- Applications which have only a few classes (a few hundred or less) spend only a small proportion of time performing class scans.? Applications with many classes (several thousand or more) can spend a large proportion of time scanning classes, with applications that have tens of thousands of classes spending up to 40% of startup time scanning classes.
- Whether a scan is performed for an application depends on the metadata-complete setting and, for CDI enabled applications, what bean discovery mode is used for the application.? If metadata-complete is set for all parts of an application, and if bean discovery mode is set to NONE, then minimal class scans are performed, and the proportion of time spent scanning classes will be very small.
Resolving The Problem
Jandex indexes provide a faster way to obtain class information.
Startup times are reduced by enabling the use of jandex indexes.
When using jandex indexes, the comprehensive scans of application classes is replaced with reads of data from jandex data placed in application archives.
This results in a significant speedup, since reading jandex indexes is much faster than performing iterative class scans.
Using jandex indexes requires two steps:
- Jandex indexes must be generated and placed in application archives.
- The Liberty configuration must be set to enable reads of the Jandex indexes.
Was this topic helpful?
Document Information
Modified date:
02 November 2020
UID
ibm10745421