From e18f15b3ccbee18c4e0341bed1480a9229eedee6 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Fri, 3 Dec 2021 15:22:38 +0200 Subject: [PATCH] [WIP] Adds debuginfo size to native-image output --- .../src/com/oracle/svm/hosted/NativeImageGenerator.java | 2 +- .../src/com/oracle/svm/hosted/image/AbstractImage.java | 5 +++++ .../src/com/oracle/svm/hosted/image/NativeImage.java | 6 ++++++ .../com/oracle/svm/hosted/reporting/ProgressReporter.java | 6 +++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java index 7391107ec7db..18c9f1a2b0c3 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java @@ -672,7 +672,7 @@ private void doRun(Map entryPoints, featureHandler.forEachFeature(feature -> feature.afterImageWrite(afterConfig)); } reporter.printCreationEnd(imageTimer, writeTimer, image.getImageSize(), bb.getUniverse(), heap.getObjectCount(), image.getImageHeapSize(), codeCache.getCodeCacheSize(), - codeCache.getCompilations().size()); + codeCache.getCompilations().size(), image.getDebugInfoSize()); if (SubstrateOptions.BuildOutputBreakdowns.getValue()) { ProgressReporter.singleton().printBreakdowns(compileQueue.getCompilationTasks(), image.getHeap().getObjects()); } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java index 3745dddc4217..708dbf89dce2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java @@ -47,6 +47,7 @@ public abstract class AbstractImage { protected final NativeImageCodeCache codeCache; protected final List entryPoints; protected int resultingImageSize; // for statistical output + protected int debugInfoSize; // for statistical output public enum NativeImageKind { SHARED_LIBRARY(false) { @@ -115,6 +116,10 @@ public int getImageSize() { return resultingImageSize; } + public int getDebugInfoSize() { + return debugInfoSize; + } + public NativeLibraries getNativeLibs() { return nativeLibs; } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java index 7f2057e9cebe..c9c054c7f6ab 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java @@ -179,6 +179,12 @@ protected final void write(DebugContext context, Path outputFile) { throw shouldNotReachHere(ex); } resultingImageSize = (int) outputFile.toFile().length(); + debugInfoSize = 0; + for (Element e : objectFile.getElements()) { + if (e.getName().contains(".debug")) { + debugInfoSize += e.getMemSize(objectFile.getDecisionsByElement()); + } + } if (NativeImageOptions.PrintImageElementSizes.getValue()) { for (Element e : objectFile.getElements()) { System.out.printf("PrintImageElementSizes: size: %15d name: %s\n", e.getMemSize(objectFile.getDecisionsByElement()), e.getElementName()); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reporting/ProgressReporter.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reporting/ProgressReporter.java index aeceab34ad23..9b276871e43f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reporting/ProgressReporter.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reporting/ProgressReporter.java @@ -328,7 +328,7 @@ public void setDebugInfoTimer(Timer timer) { } public void printCreationEnd(Timer creationTimer, Timer writeTimer, int imageSize, AnalysisUniverse universe, int numHeapObjects, long imageHeapSize, int codeCacheSize, - int numCompilations) { + int numCompilations, int debugInfoSize) { printStageEnd(creationTimer.getTotalTime() + writeTimer.getTotalTime()); String total = bytesToHuman("%4.2f", imageSize); l().a("%9s in total (%2.2f%% for ", total, codeCacheSize / (double) imageSize * 100).doclink("code area", "#glossary-code-area") @@ -336,6 +336,10 @@ public void printCreationEnd(Timer creationTimer, Timer writeTimer, int imageSiz l().a("%9s in code size: %,8d compilation units", bytesToHuman("%4.2f", codeCacheSize), numCompilations).flushln(); long numInstantiatedClasses = universe.getTypes().stream().filter(t -> t.isInstantiated()).count(); l().a("%9s in heap size: %,8d classes and %,d objects", bytesToHuman("%4.2f", imageHeapSize), numInstantiatedClasses, numHeapObjects).flushln(); + if (debugInfoSize > 0) { + // TODO print number of DIEs etc. + l().a("%9s in debugInfo size", bytesToHuman("%4.2f", debugInfoSize)).flushln(); + } if (debugInfoTimer != null) { String debugInfoTime = String.format("%.1fs", millisToSeconds(debugInfoTimer.getTotalTime())); l().dim().a("%9s for generating debug info", debugInfoTime).reset().flushln();