Implementing the OpenJ9 shared class cache for applications in containers
The Eclipse OpenJ9 shared class cache (SCC) enables the VM to store Java™ classes, JIT compiled code, and profiling data in an optimized form that can load quickly. Multiple VMs can share the SCC, which reduces total memory consumption.
WebSphere® Liberty container images contain an
SCC and (by default) add your application's specific data to the SCC at image build time when your
Dockerfile runs the RUN configure.sh
command.
Some content in the SCC is sensitive to heap geometry. If you change the heap geometry after the
SCC is created, server restarts can result in fluctuations in start-up performance and such content
not being used. Specifying a smaller -Xmx
value increases the chances of obtaining
a heap geometry that is compatible with the AOT code.
To control this feature, use the following variable:
OPENJ9_SCC
(environment variable)- If
true
, cache application-specific data in an SCC and include it in the image. A new SCC is created if needed, otherwise data are added to the existing SCC. The default value istrue
. TRIM_SCC
(environment variable)- If
true
, the application-specific SCC layer is sized-down to accommodate only the data populated during image build process. To allow the application to add more data to the SCC at runtime, set theTRIM_SCC
environment variable tofalse
and ensure that the SCC is not marked as read-only in theOPENJ9_JAVA_OPTIONS
environment variable. The following example sets theOPENJ9_JAVA_OPTIONS
environment variable in the application Dockerfile.
TheOPENJ9_JAVA_OPTIONS="-XX:+IgnoreUnrecognizedVMOptions -XX:+IdleTuningGcOnIdle -Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc,nonFatal -Dosgi.checkConfiguration=false"
OPENJ9_JAVA_OPTIONS
environment variable is defined in the base Liberty image Dockerfile, but includes thereadonly
sub-option. The default value istrue
. SCC_SIZE
(environment variable)- The size of the application-specific SCC layer in the image. The value of the
SCC_SIZE
environment variable is only used if theTRIM_SCC
environment variable is set tofalse
. The default value is80m
. WARM_ENDPOINT
(environment variable)- If
true
, curl is used to access theWARM_ENDPOINT_URL
environment variable during the population of the SCC. The amount of information in the SCC increases and first request time in subsequent starts of the image improves. The default value istrue
. WARM_ENDPOINT_URL
(environment variable)- The URL to access during SCC population if the
WARM_ENDPOINT
environment variable is set totrue
. The default value islocalhost:9080/
. WARM_OPENAPI_ENDPOINT
(environment variable)- If
true
, curl is used to access theWARM_OPENAPI_ENDPOINT_URL
environment variable during the population of the SCC. The amount of information in the SCC increases and first request time in subsequent starts of the image improves. The default value istrue
. WARM_OPENAPI_ENDPOINT_URL
(environment variable)- The URL to access during SCC population if the
WARM_OPENAPI_ENDPOINT
environment variable istrue
. The default value islocalhost:9080/openapi
.