From 4a5400ac9a03f0db0ab16009d41c6557fa37a51c Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 19 Jun 2023 09:27:03 +0200 Subject: [PATCH] Extend build reports with new data. Updated schema: https://github.com/oracle/graal/blob/f196ab032500dece54c35b68e2e6190be4222526/docs/reference-manual/native-image/assets/build-output-schema-v0.9.1.json --- dist/cleanup/index.js | 108 +++++++++++++++++++++++--------- dist/main/index.js | 108 +++++++++++++++++++++++--------- src/features/reports.ts | 133 ++++++++++++++++++++++++++++++---------- 3 files changed, 259 insertions(+), 90 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 9965ccb..b5190a3 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -70227,9 +70227,9 @@ function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) if (!isRequired) { return; } - const isSupported = graalVMVersion === c.VERSION_LATEST || + const isSupported = isGraalVMforJDK17OrLater || + graalVMVersion === c.VERSION_LATEST || graalVMVersion === c.VERSION_DEV || - isGraalVMforJDK17OrLater || (!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) && (0, semver_1.gte)((0, utils_1.toSemVer)(graalVMVersion), '22.2.0')); if (!isSupported) { @@ -70287,7 +70287,12 @@ function createReport(data) { const context = github.context; const info = data.general_info; const analysis = data.analysis_results; + const analysisTypes = analysis.types ? analysis.types : analysis.classes; const details = data.image_details; + let objectCount = ''; + if (details.image_heap.objects) { + objectCount = `${details.image_heap.objects.count.toLocaleString()} objects, `; + } const debugInfoBytes = details.debug_info ? details.debug_info.bytes : 0; const otherBytes = details.total_bytes - details.code_area.bytes - @@ -70303,25 +70308,64 @@ function createReport(data) { `; } + let versionLine; + if (info.vendor_version) { + versionLine = ` + + Java version + ${info.java_version} + Vendor version + ${info.vendor_version} + `; + } + else { + versionLine = ` + + GraalVM version + ${info.graalvm_version} + Java version + ${info.java_version} + `; + } + let graalLine; + if (info.graal_compiler) { + let pgoSuffix = ''; + const isOracleGraalVM = info.vendor_version && info.vendor_version.includes('Oracle GraalVM'); + if (isOracleGraalVM) { + const pgo = info.graal_compiler.pgo; + const pgoText = pgo ? pgo.join('+') : 'off'; + pgoSuffix = `, PGO: ${pgoText}`; + } + graalLine = ` + + Graal compiler + + optimization level: ${info.graal_compiler.optimization_level}, + target machine: ${info.graal_compiler.march}${pgoSuffix} + + `; + } const resources = data.resource_usage; + let totalTime = ''; + let gcTotalTimeRatio = ''; + if (resources.total_secs) { + totalTime = ` in ${secondsToHuman(resources.total_secs)}`; + gcTotalTimeRatio = ` (${toPercent(resources.garbage_collection.total_secs, resources.total_secs)} of total time)`; + } return `## GraalVM Native Image Build Report -\`${info.name}\` generated as part of the '${context.job}' job in run #${context.runNumber}. +\`${info.name}\` generated${totalTime} as part of the '${context.job}' job in run #${context.runNumber}. #### Environment - +
${versionLine}${graalLine} - - - + - - - +
GraalVM version${info.graalvm_version} C compiler${info.c_compiler}${info.c_compiler}
Java version${info.java_version} Garbage collector${info.garbage_collector}${info.garbage_collector}
@@ -70342,38 +70386,38 @@ function createReport(data) { Reachable - ${analysis.classes.reachable} - ${toPercent(analysis.classes.reachable, analysis.classes.total)} - ${analysis.fields.reachable} + ${analysisTypes.reachable.toLocaleString()} + ${toPercent(analysisTypes.reachable, analysisTypes.total)} + ${analysis.fields.reachable.toLocaleString()} ${toPercent(analysis.fields.reachable, analysis.fields.total)} - ${analysis.methods.reachable} + ${analysis.methods.reachable.toLocaleString()} ${toPercent(analysis.methods.reachable, analysis.methods.total)} Reflection - ${analysis.classes.reflection} - ${toPercent(analysis.classes.reflection, analysis.classes.total)} - ${analysis.fields.reflection} + ${analysisTypes.reflection.toLocaleString()} + ${toPercent(analysisTypes.reflection, analysisTypes.total)} + ${analysis.fields.reflection.toLocaleString()} ${toPercent(analysis.fields.reflection, analysis.fields.total)} - ${analysis.methods.reflection} + ${analysis.methods.reflection.toLocaleString()} ${toPercent(analysis.methods.reflection, analysis.methods.total)} JNI - ${analysis.classes.jni} - ${toPercent(analysis.classes.jni, analysis.classes.total)} - ${analysis.fields.jni} + ${analysisTypes.jni.toLocaleString()} + ${toPercent(analysisTypes.jni, analysisTypes.total)} + ${analysis.fields.jni.toLocaleString()} ${toPercent(analysis.fields.jni, analysis.fields.total)} - ${analysis.methods.jni} + ${analysis.methods.jni.toLocaleString()} ${toPercent(analysis.methods.jni, analysis.methods.total)} Loaded - ${analysis.classes.total} + ${analysisTypes.total.toLocaleString()} 100.000% - ${analysis.fields.total} + ${analysis.fields.total.toLocaleString()} 100.000% - ${analysis.methods.total} + ${analysis.methods.total.toLocaleString()} 100.000% @@ -70395,13 +70439,13 @@ function createReport(data) { Code area ${bytesToHuman(details.code_area.bytes)} ${toPercent(details.code_area.bytes, details.total_bytes)} - ${details.code_area.compilation_units} compilation units + ${details.code_area.compilation_units.toLocaleString()} compilation units Image heap ${bytesToHuman(details.image_heap.bytes)} ${toPercent(details.image_heap.bytes, details.total_bytes)} - ${bytesToHuman(details.image_heap.resources.bytes)} for ${details.image_heap.resources.count} resources + ${objectCount}${bytesToHuman(details.image_heap.resources.bytes)} for ${details.image_heap.resources.count.toLocaleString()} resources ${debugInfoLine} Other data @@ -70424,7 +70468,7 @@ function createReport(data) { Garbage collection - ${resources.garbage_collection.total_secs.toFixed(2)}s in ${resources.garbage_collection.count} GCs + ${resources.garbage_collection.total_secs.toFixed(2)}s${gcTotalTimeRatio} in ${resources.garbage_collection.count} GCs Peak RSS @@ -70456,6 +70500,14 @@ function bytesToHuman(bytes) { return `${(bytes / BYTES_TO_GiB).toFixed(2)}GB`; } } +function secondsToHuman(seconds) { + if (seconds < 60) { + return `${seconds.toFixed(1)}s`; + } + else { + return `${Math.trunc(seconds / 60)}m ${Math.trunc(seconds % 60)}s`; + } +} /***/ }), diff --git a/dist/main/index.js b/dist/main/index.js index e9d0fa5..faa8001 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -70345,9 +70345,9 @@ function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) if (!isRequired) { return; } - const isSupported = graalVMVersion === c.VERSION_LATEST || + const isSupported = isGraalVMforJDK17OrLater || + graalVMVersion === c.VERSION_LATEST || graalVMVersion === c.VERSION_DEV || - isGraalVMforJDK17OrLater || (!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) && (0, semver_1.gte)((0, utils_1.toSemVer)(graalVMVersion), '22.2.0')); if (!isSupported) { @@ -70405,7 +70405,12 @@ function createReport(data) { const context = github.context; const info = data.general_info; const analysis = data.analysis_results; + const analysisTypes = analysis.types ? analysis.types : analysis.classes; const details = data.image_details; + let objectCount = ''; + if (details.image_heap.objects) { + objectCount = `${details.image_heap.objects.count.toLocaleString()} objects, `; + } const debugInfoBytes = details.debug_info ? details.debug_info.bytes : 0; const otherBytes = details.total_bytes - details.code_area.bytes - @@ -70421,25 +70426,64 @@ function createReport(data) { `; } + let versionLine; + if (info.vendor_version) { + versionLine = ` + + Java version + ${info.java_version} + Vendor version + ${info.vendor_version} + `; + } + else { + versionLine = ` + + GraalVM version + ${info.graalvm_version} + Java version + ${info.java_version} + `; + } + let graalLine; + if (info.graal_compiler) { + let pgoSuffix = ''; + const isOracleGraalVM = info.vendor_version && info.vendor_version.includes('Oracle GraalVM'); + if (isOracleGraalVM) { + const pgo = info.graal_compiler.pgo; + const pgoText = pgo ? pgo.join('+') : 'off'; + pgoSuffix = `, PGO: ${pgoText}`; + } + graalLine = ` + + Graal compiler + + optimization level: ${info.graal_compiler.optimization_level}, + target machine: ${info.graal_compiler.march}${pgoSuffix} + + `; + } const resources = data.resource_usage; + let totalTime = ''; + let gcTotalTimeRatio = ''; + if (resources.total_secs) { + totalTime = ` in ${secondsToHuman(resources.total_secs)}`; + gcTotalTimeRatio = ` (${toPercent(resources.garbage_collection.total_secs, resources.total_secs)} of total time)`; + } return `## GraalVM Native Image Build Report -\`${info.name}\` generated as part of the '${context.job}' job in run #${context.runNumber}. +\`${info.name}\` generated${totalTime} as part of the '${context.job}' job in run #${context.runNumber}. #### Environment - +
${versionLine}${graalLine} - - - + - - - +
GraalVM version${info.graalvm_version} C compiler${info.c_compiler}${info.c_compiler}
Java version${info.java_version} Garbage collector${info.garbage_collector}${info.garbage_collector}
@@ -70460,38 +70504,38 @@ function createReport(data) { Reachable - ${analysis.classes.reachable} - ${toPercent(analysis.classes.reachable, analysis.classes.total)} - ${analysis.fields.reachable} + ${analysisTypes.reachable.toLocaleString()} + ${toPercent(analysisTypes.reachable, analysisTypes.total)} + ${analysis.fields.reachable.toLocaleString()} ${toPercent(analysis.fields.reachable, analysis.fields.total)} - ${analysis.methods.reachable} + ${analysis.methods.reachable.toLocaleString()} ${toPercent(analysis.methods.reachable, analysis.methods.total)} Reflection - ${analysis.classes.reflection} - ${toPercent(analysis.classes.reflection, analysis.classes.total)} - ${analysis.fields.reflection} + ${analysisTypes.reflection.toLocaleString()} + ${toPercent(analysisTypes.reflection, analysisTypes.total)} + ${analysis.fields.reflection.toLocaleString()} ${toPercent(analysis.fields.reflection, analysis.fields.total)} - ${analysis.methods.reflection} + ${analysis.methods.reflection.toLocaleString()} ${toPercent(analysis.methods.reflection, analysis.methods.total)} JNI - ${analysis.classes.jni} - ${toPercent(analysis.classes.jni, analysis.classes.total)} - ${analysis.fields.jni} + ${analysisTypes.jni.toLocaleString()} + ${toPercent(analysisTypes.jni, analysisTypes.total)} + ${analysis.fields.jni.toLocaleString()} ${toPercent(analysis.fields.jni, analysis.fields.total)} - ${analysis.methods.jni} + ${analysis.methods.jni.toLocaleString()} ${toPercent(analysis.methods.jni, analysis.methods.total)} Loaded - ${analysis.classes.total} + ${analysisTypes.total.toLocaleString()} 100.000% - ${analysis.fields.total} + ${analysis.fields.total.toLocaleString()} 100.000% - ${analysis.methods.total} + ${analysis.methods.total.toLocaleString()} 100.000% @@ -70513,13 +70557,13 @@ function createReport(data) { Code area ${bytesToHuman(details.code_area.bytes)} ${toPercent(details.code_area.bytes, details.total_bytes)} - ${details.code_area.compilation_units} compilation units + ${details.code_area.compilation_units.toLocaleString()} compilation units Image heap ${bytesToHuman(details.image_heap.bytes)} ${toPercent(details.image_heap.bytes, details.total_bytes)} - ${bytesToHuman(details.image_heap.resources.bytes)} for ${details.image_heap.resources.count} resources + ${objectCount}${bytesToHuman(details.image_heap.resources.bytes)} for ${details.image_heap.resources.count.toLocaleString()} resources ${debugInfoLine} Other data @@ -70542,7 +70586,7 @@ function createReport(data) { Garbage collection - ${resources.garbage_collection.total_secs.toFixed(2)}s in ${resources.garbage_collection.count} GCs + ${resources.garbage_collection.total_secs.toFixed(2)}s${gcTotalTimeRatio} in ${resources.garbage_collection.count} GCs Peak RSS @@ -70574,6 +70618,14 @@ function bytesToHuman(bytes) { return `${(bytes / BYTES_TO_GiB).toFixed(2)}GB`; } } +function secondsToHuman(seconds) { + if (seconds < 60) { + return `${seconds.toFixed(1)}s`; + } + else { + return `${Math.trunc(seconds / 60)}m ${Math.trunc(seconds % 60)}s`; + } +} /***/ }), diff --git a/src/features/reports.ts b/src/features/reports.ts index 5021521..0a688db 100644 --- a/src/features/reports.ts +++ b/src/features/reports.ts @@ -33,11 +33,18 @@ interface BuildOutput { name: string graalvm_version: string java_version: string | null + vendor_version?: string c_compiler: string | null garbage_collector: string + graal_compiler?: { + optimization_level: string + march: string + pgo?: string[] + } } analysis_results: { classes: AnalysisResult + types?: AnalysisResult fields: AnalysisResult methods: AnalysisResult } @@ -49,6 +56,9 @@ interface BuildOutput { } image_heap: { bytes: number + objects?: { + count: number + } resources: { count: number bytes: number @@ -75,6 +85,7 @@ interface BuildOutput { system_total: number peak_rss_bytes: number } + total_secs?: number } } @@ -87,9 +98,9 @@ export async function setUpNativeImageBuildReports( return } const isSupported = + isGraalVMforJDK17OrLater || graalVMVersion === c.VERSION_LATEST || graalVMVersion === c.VERSION_DEV || - isGraalVMforJDK17OrLater || (!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) && gte(toSemVer(graalVMVersion), '22.2.0')) if (!isSupported) { @@ -155,7 +166,12 @@ function createReport(data: BuildOutput): string { const context = github.context const info = data.general_info const analysis = data.analysis_results + const analysisTypes = analysis.types ? analysis.types : analysis.classes const details = data.image_details + let objectCount = '' + if (details.image_heap.objects) { + objectCount = `${details.image_heap.objects.count.toLocaleString()} objects, ` + } const debugInfoBytes = details.debug_info ? details.debug_info.bytes : 0 const otherBytes = details.total_bytes - @@ -172,12 +188,59 @@ function createReport(data: BuildOutput): string { ` } + let versionLine + if (info.vendor_version) { + versionLine = ` + + Java version + ${info.java_version} + Vendor version + ${info.vendor_version} + ` + } else { + versionLine = ` + + GraalVM version + ${info.graalvm_version} + Java version + ${info.java_version} + ` + } + let graalLine + if (info.graal_compiler) { + let pgoSuffix = '' + const isOracleGraalVM = + info.vendor_version && info.vendor_version.includes('Oracle GraalVM') + if (isOracleGraalVM) { + const pgo = info.graal_compiler.pgo + const pgoText = pgo ? pgo.join('+') : 'off' + pgoSuffix = `, PGO: ${pgoText}` + } + graalLine = ` + + Graal compiler + + optimization level: ${info.graal_compiler.optimization_level}, + target machine: ${info.graal_compiler.march}${pgoSuffix} + + ` + } const resources = data.resource_usage + let totalTime = '' + let gcTotalTimeRatio = '' + if (resources.total_secs) { + totalTime = ` in ${secondsToHuman(resources.total_secs)}` + gcTotalTimeRatio = ` (${toPercent( + resources.garbage_collection.total_secs, + resources.total_secs + )} of total time)` + } + return `## GraalVM Native Image Build Report -\`${info.name}\` generated as part of the '${ +\`${info.name}\` generated${totalTime} as part of the '${ context.job }' job in run GraalVM version - ${info.graalvm_version} C compiler - ${info.c_compiler} + ${info.c_compiler} - Java version - ${info.java_version} Garbage collector - ${info.garbage_collector} + ${info.garbage_collector} @@ -217,17 +276,17 @@ function createReport(data: BuildOutput): string { Reachable - ${analysis.classes.reachable} + ${analysisTypes.reachable.toLocaleString()} ${toPercent( - analysis.classes.reachable, - analysis.classes.total + analysisTypes.reachable, + analysisTypes.total )} - ${analysis.fields.reachable} + ${analysis.fields.reachable.toLocaleString()} ${toPercent( analysis.fields.reachable, analysis.fields.total )} - ${analysis.methods.reachable} + ${analysis.methods.reachable.toLocaleString()} ${toPercent( analysis.methods.reachable, analysis.methods.total @@ -235,17 +294,17 @@ function createReport(data: BuildOutput): string { Reflection - ${analysis.classes.reflection} + ${analysisTypes.reflection.toLocaleString()} ${toPercent( - analysis.classes.reflection, - analysis.classes.total + analysisTypes.reflection, + analysisTypes.total )} - ${analysis.fields.reflection} + ${analysis.fields.reflection.toLocaleString()} ${toPercent( analysis.fields.reflection, analysis.fields.total )} - ${analysis.methods.reflection} + ${analysis.methods.reflection.toLocaleString()} ${toPercent( analysis.methods.reflection, analysis.methods.total @@ -253,17 +312,17 @@ function createReport(data: BuildOutput): string { JNI - ${analysis.classes.jni} + ${analysisTypes.jni.toLocaleString()} ${toPercent( - analysis.classes.jni, - analysis.classes.total + analysisTypes.jni, + analysisTypes.total )} - ${analysis.fields.jni} + ${analysis.fields.jni.toLocaleString()} ${toPercent( analysis.fields.jni, analysis.fields.total )} - ${analysis.methods.jni} + ${analysis.methods.jni.toLocaleString()} ${toPercent( analysis.methods.jni, analysis.methods.total @@ -271,11 +330,11 @@ function createReport(data: BuildOutput): string { Loaded - ${analysis.classes.total} + ${analysisTypes.total.toLocaleString()} 100.000% - ${analysis.fields.total} + ${analysis.fields.total.toLocaleString()} 100.000% - ${analysis.methods.total} + ${analysis.methods.total.toLocaleString()} 100.000% @@ -300,9 +359,7 @@ function createReport(data: BuildOutput): string { details.code_area.bytes, details.total_bytes )} - ${ - details.code_area.compilation_units - } compilation units + ${details.code_area.compilation_units.toLocaleString()} compilation units Image heap @@ -311,9 +368,9 @@ function createReport(data: BuildOutput): string { details.image_heap.bytes, details.total_bytes )} - ${bytesToHuman( - details.image_heap.resources.bytes - )} for ${details.image_heap.resources.count} resources + ${objectCount}${bytesToHuman( + details.image_heap.resources.bytes + )} for ${details.image_heap.resources.count.toLocaleString()} resources ${debugInfoLine} Other data @@ -340,7 +397,7 @@ function createReport(data: BuildOutput): string { Garbage collection ${resources.garbage_collection.total_secs.toFixed( 2 - )}s in ${resources.garbage_collection.count} GCs + )}s${gcTotalTimeRatio} in ${resources.garbage_collection.count} GCs Peak RSS @@ -379,3 +436,11 @@ function bytesToHuman(bytes: number): string { return `${(bytes / BYTES_TO_GiB).toFixed(2)}GB` } } + +function secondsToHuman(seconds: number): string { + if (seconds < 60) { + return `${seconds.toFixed(1)}s` + } else { + return `${Math.trunc(seconds / 60)}m ${Math.trunc(seconds % 60)}s` + } +}