Using Cloud Native Compiler’s (CNC) Compiler Service involves two distinct phases:
-
Recording a good profile that accurately captures the usage pattern you want to warm up. This often includes using several training iterations to get a complete profile.
-
Using the profile as the input to newly started VMs.
Using the CNC Profile Log Service to record and serve profiles greatly simplifies the operational use of the CNC Compiler Service.
Creating and Writing To a New Profile Name
CNC allows users of Azul Prime to record and distribute ReadyNow profiles with intervention of a CNC administrator. All of the necessary options can be specified as command-line arguments to the Java process at the time of deployment.
When using ReadyNow with CNC, responsibilities are split between the JVM and CNC:
-
The JVM says what profile name it wants to read from and write to. The JVM also decides when to nominate the profile log as a candidate for use by other JVMs based on its minimum recording time. The JVM can additionally decide when to stop writing a log based on log size or maximum recording time.
-
CNC handles recording and storing all of the profile candidates the JVMs send it. CNC promotes one of the candidates as the best version of the profile to send the clients.
-
Recording: Profiles are transmitted continuously to CNC. No caching will be performed inside the JVM. Even if the JVM terminates irregularley or the network connection is lost the profile maybe useable.
-
Promotion: Promotion for use as the new default profile for newly started JVM is performed by the CNC server.
Profile Log Service Commands
The following options are available in Azul Prime when using the Profile Log Service with CNC:
Option |
Description |
Default |
-XX:ProfileLogOut=<filename> |
The ProfileLogOut enables Azul Zulu Prime JVM to record compilations from the current run. <filename> is the name of the profile that the JVM reads as input to ReadyNow. If prefixed with cnc:// , it will attempt to pull the profile from Cloud Native Compiler.
If ReadyNow is configured as a rolling profile (with ProfileLogIn equal to ProfileLogOut), The JVM creates a backup of the input profile at startup before the profile is being read into memory. Otherwise, the file will be overwritten. |
null |
-XX:ProfileLogIn=<filename> |
The ProfileLogIn allows Azul Zulu Prime JVM to base its decisions on the information from a previous run. The current ProfileLogIn file information will be read in its entirety - before Azul Zulu Prime JVM starts to create a new ProfileLogOut log. <filename> is the name of the profile that the JVM reads as input to ReadyNow. If prefixed with cnc:// , it will attempt to pull the profile from Cloud Native Compiler. |
null |
-XX:ProfileLogName |
Name of the profile that the JVM both reads from and writes to. If prefixed with cnc:// , it will attempt to write from Cloud Native Compiler.
Replaces ProfileLogIn and ProfileLogOut. Can be used in place of -XX:ProfileLogIn=<profile1> -XX:ProfileLogOut=<profile1> |
null |
-XX:ProfileLogOutNominationMinSize |
Indicate to server that the produced profile is eligible for promotion after specified amount of bytes recorded.
0 = any size eligible, -1 means it will never be promoted |
1m |
-XX:ProfileLogOutNominationMinTimeSec |
When used with Cloud Native Compiler, the minimum time, in seconds, a profile must record before CNC will nominate it as a candidate. If no -XX:ProfileLogOutNominationMinTimeSec is set, then the candidate is nominated by CNC when -XX:ProfileLogTimeLimitSeconds is reached.
0 = any duration eligible, -1 means it will never be promoted |
120 |
-XX:ProfileLogOutMaxNominatedGenerationCount |
When used with Cloud Native Compiler, specifies the maximum generation of a profile that a VM will nominate. If ContinueRecordingAfterPromotion (CNC server-side parameter) is set to false (default), then the JVM will not output another generation after this limit has been reached. If ContinueRecordingAfterPromotion is true, the JVM will output another generation to Cloud Native Compiler but will never nominate it. These additional generations are for debugging and analysis only.
0 = unlimited |
0 |
-XX:ProfileLogMaxSize=<value in bytes> |
Specifies the maximum size that a ReadyNow! profile log is allowed to reach. Profiles will be truncated at this size, regardless of whether the application has actually been completely warmed up. It is recommended to either not set this size explicitly, or set it generously if required, for example:
-XX:ProfileLogMaxSize=1G
0 = unlimited |
0 |
-XX:ProfileLogTimeLimitSeconds=<value in seconds> |
Instructs ReadyNow! to stop adding to the profile log after a period of N seconds regardless of where the application has been completely warmed up. It is recommended to either not set this size explicitly, or set it generously if required.
0 = unlimited |
0 |
-XX:ProfileLogDumpInputToFile=<name> |
Dump input profile to the specified path. For debugging purposes only. |
null |
-XX:ProfileLogDumpOutputToFile=<name> |
Dump output profile to the specified path. For debugging purposes only. |
null |
-XX:ProfileLogServiceConnectionTimeoutMillis |
Timeout on establishing remote connection and timeout on interval between downloading two chunks. Specified in milliseconds. |
5000 |
-XX:ProfileLogOutVerbose |
Enables logging of verbose, optional tracing information in -XX:ProfileLogOut |
true |
Substitution Macros
It is possible to use substitution macros. Each macro unfolds to a 4-byte hash string taken from a particular plain-text string corresponding to a property:
Macro |
Description |
|
Hashed user-defined Java class path string |
|
Hashed JVM arguments string |
|
Hashed JVM flags string |
|
Hashed string containing all plain-text values from above macros. Input values are concatenated to one string: Java class path string + JVM arguments string + JVM flags string. Afterwards, 4-bytes hash is applied to concatenated result. |
|
Hashed JDK version number converted to string |
|
Hashed JVM version number converted to string |
Profile Log Service Global Defaults
CNC admins can also set the following global defaults for ReadyNow profiles:
Option |
Description |
Default |
persistentprofile.storage-service |
Decide back-end storage. Only s3 is supported at the moment |
s3 |
persistentprofile.bucket |
Name of the s3 bucket to use for storage |
persistent-profile |
persistentprofile.debug-info-history-length |
Limit of rolling profile history entries |
100 |
persistentprofile.cache.enabled |
Enabling of caching the chunk content on the gateway |
false |
persistentprofile.producers.max-concurrent-recordings |
The number of concurrent copies of a specific generation CNC will accept before it tells other JVMs trying to write the same generation of the same Profile Name to stop |
5 |
persistentprofile.producers.max-promotable-generation |
Maximum number of generations CNC will accept for a Profile Name. Note that here is no 'unlimited' value available |
3 |
persistentprofile.producers.max-profile-size |
Limit on the input profile size, no limit by default |
0 |
persistentprofile.producers.continue-recording-on-promotion |
If set to true, CNC keeps accepting new logs even after -XX:ProfileLogOutMaxNominatedGenerationCount has been reached. These profile logs are for debugging purposes. All profile logs are recorded in the generation -XX:ProfileLogOutMaxNominatedGenerationCount +1 and are never promoted. |
false |
persistentprofile.cleaner.enabled |
Enabling of automatic repository clean-up |
false |
persistentprofile.cleaner.target-size |
Target amount of data stored in the repository |
0 |
persistentprofile.cleaner.warning-size |
Warning amount of data stored in the repository |
0 |
Basic Profile Recording with Server Defaults
In its most basic form, you just let the server-side defaults do all the work. By default, CNC will nominate profile logs after three full generations and does not place a limit on log size. Suppose you want to record a new profile while deploying code to a fleet running in production. Run with the following options:
java -XX:CNCHost=TestEnvCncHost \
-XX:ProfileLogName=cnc://MyApp-v3 \
-jar myapp.jar
In this case, all JVMs nominate their logs for promotion after two minutes of recording and keep recording until the JVM shuts down. For best results, do a test run in a canary instance for at least two minutes and if possible a full ten minutes. This creates generation 1 of your profile. Then restart your fleet as normal. As JVMs start up, they receive a profile from CNC and check the generation number. If that number is less than the server-side default maximum of 3, the JVM writes out the next generation of the profile. Once there is a valid generation 3 of the profile on CNC, none of the JVMs write any more output.
Capping Profile Log Recording and Maximum Generations
We can make our example above more complex:
A profile needs to record for at least 2 minutes to be nominated.
After 10 minutes you want to stop recording.
You want to record two generations of the profile.
Start your JVM with the following parameters:
java -XX:CNCHost=TestEnvCncHost \
-XX:ProfileLogName=cnc://MyApp-v3 \
-XX:ProfileLogTimeLimitSeconds=600 \
-XX:ProfileLogMaxNominatedGenerationCount=2 \
-jar myapp.jar
You often want to keep recording after you have a valid profile that your JVMs can use. This allows you to review your ReadyNow information later to analyze new traffic patterns or debug unwanted application behavior. To continue recording after the maximum generation has been reached, CNC Admin sets StopRecordingOnMaxGeneration=false
. In the above example, all JVMs who start and receive a valid generation 3 profile write out a profile log to generation 4 of MyApp-v3 but never nominates them for use by other JVMs. CNC will never send generation 4 of a profile to a JVM. You can access these diagnostic profiles through the administrative REST APIs.
Using a Previous Profile as the Basis of a New Profile Recording
When you’re deploying version 3 of MyApp, you often have a valid profile for version 2. In most cases, you change a small portion of your code between versions and most of the previous profile is still valid for your new version. When you feed in the previous version of the profile as input to recording the new version of the profile, you can in most cases eliminate the need to do multiple training iterations.
Using our above example, perform one run of the full ten minutes in a canary with the following settings:
java -XX:CNCHost=TestEnvCncHost \
-XX:ProfileLogIn=cnc://MyApp-v2 \
-XX:ProfileLogOut=cnc://MyApp-v3 \
-XX:ProfileLogTimeLimitSeconds=600 \
-XX:ProfileLogMaxNominatedGenerationCount=1 \
-jar myapp.jar
To restart the rest of your fleet with the following settings:
java -XX:CNCHost=TestEnvCncHost \
-XX:ProfileLogName=cnc://MyApp-v3 \
-XX:ProfileLogTimeLimitSeconds=600 \
-XX:ProfileLogMaxNominatedGenerationCount=1 \
-jar myapp.jar