-
Notifications
You must be signed in to change notification settings - Fork 201
Start up time improvement with a limited number of CPU cores (experimental)
This feature is experimental today. If it allows you to reduce your startup time with Application Insights or run your application using fewer CPU cores, don't hesitate to create an issue with your results. We may then consider official support for this feature.
Prerequisites:
- Application Insights version >= 3.4.6
- Java >=9
- Non OpenJ9 JVM
The feature disables the JVM C2 compiler during the Application Insights initialization and re-enables it after.
First, create a jvm-disable-c2.json
file with the following content:
[
{
match: [
"*::*"
],
c2: {
Exclude: true
}
}
]
After that, add -XX:+UnlockDiagnosticVMOptions -XX:CompilerDirectivesFile=jvm-disable-c2.json -Dapplicationinsights.experiment.clear-compiler-directives-after-initialization=true
to your JVM configuration.
An example with a Dockerfile
:
COPY jvm-disable-c2.json jvm-disable-c2.json
CMD ["java", "-javaagent:/agents/applicationinsights-agent-3.4.6.jar", "-XX:+UnlockDiagnosticVMOptions", "-XX:CompilerDirectivesFile=jvm-disable-c2.json", "-Dapplicationinsights.experiment.clear-compiler-directives-after-initialization=true", "-jar", "/app.jar"]
You should see 1 compiler directives added
in the standard output.
-Dapplicationinsights.experiment.clear-compiler-directives-after-initialization=true
property. Without this, your application may become slow.
You can measure the agent initialization time from the JVM running for
part of the following log type:
INFO c.m.applicationinsights.agent - Application Insights Java Agent 3.4.6 started successfully (PID 3196, JVM running for 10.496 s).
You can do this with and without this feature and compare the results.