Skip to content

Commit 6bb9314

Browse files
committed
Refactor timers to account for layer archiving.
1 parent 1e8adf8 commit 6bb9314

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/util/TimerCollection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public enum Registry {
5959
LAYOUT("layout"),
6060
DEBUG_INFO("dbginfo"),
6161
IMAGE("image"),
62-
WRITE("write");
62+
WRITE("write"),
63+
ARCHIVE_LAYER("archive-layer");
6364

6465
public final String name;
6566

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,7 @@ public void run(Map<Method, CEntryPointData> entryPoints,
548548

549549
try (TemporaryBuildDirectoryProviderImpl tempDirectoryProvider = new TemporaryBuildDirectoryProviderImpl()) {
550550
ImageSingletons.add(TemporaryBuildDirectoryProvider.class, tempDirectoryProvider);
551-
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
552-
HostedImageLayerBuildingSupport.setupImageLayerArtifacts(imageName);
553-
}
554551
doRun(entryPoints, javaMainSupport, imageName, k, harnessSubstitutions);
555-
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
556-
ImageSingletonsSupportImpl.HostedManagement.persist();
557-
HostedImageLayerBuildingSupport.singleton().archiveLayer(imageName);
558-
}
559552
} finally {
560553
reporter.ensureCreationStageEndCompleted();
561554
}
@@ -587,7 +580,7 @@ protected void doRun(Map<Method, CEntryPointData> entryPoints, JavaMainSupport j
587580

588581
try (DebugContext debug = new Builder(options, new GraalDebugHandlersFactory(GraalAccess.getOriginalSnippetReflection())).build();
589582
DebugCloseable featureCleanup = () -> featureHandler.forEachFeature(Feature::cleanup)) {
590-
setupNativeImage(options, entryPoints, javaMainSupport, harnessSubstitutions, debug);
583+
setupNativeImage(imageName, options, entryPoints, javaMainSupport, harnessSubstitutions, debug);
591584

592585
boolean returnAfterAnalysis = runPointsToAnalysis(imageName, options, debug);
593586
if (returnAfterAnalysis) {
@@ -780,6 +773,12 @@ protected void doRun(Map<Method, CEntryPointData> entryPoints, JavaMainSupport j
780773
AfterImageWriteAccessImpl afterConfig = new AfterImageWriteAccessImpl(featureHandler, loader, hUniverse, inv, tmpDir, image.getImageKind(), debug);
781774
featureHandler.forEachFeature(feature -> feature.afterImageWrite(afterConfig));
782775
}
776+
try (StopTimer t = TimerCollection.createTimerAndStart(TimerCollection.Registry.ARCHIVE_LAYER)) {
777+
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
778+
ImageSingletonsSupportImpl.HostedManagement.persist();
779+
HostedImageLayerBuildingSupport.singleton().archiveLayer(imageName);
780+
}
781+
}
783782
reporter.printCreationEnd(image.getImageFileSize(), heap.getLayerObjectCount(), image.getImageHeapSize(), codeCache.getCodeAreaSize(), numCompilations, image.getDebugInfoSize());
784783
}
785784
}
@@ -916,10 +915,13 @@ protected boolean verifyAssignableTypes() {
916915
}
917916

918917
@SuppressWarnings("try")
919-
protected void setupNativeImage(OptionValues options, Map<Method, CEntryPointData> entryPoints, JavaMainSupport javaMainSupport,
918+
protected void setupNativeImage(String imageName, OptionValues options, Map<Method, CEntryPointData> entryPoints, JavaMainSupport javaMainSupport,
920919
SubstitutionProcessor harnessSubstitutions, DebugContext debug) {
921920
try (Indent ignored = debug.logAndIndent("setup native-image builder")) {
922921
try (StopTimer ignored1 = TimerCollection.createTimerAndStart(TimerCollection.Registry.SETUP)) {
922+
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
923+
HostedImageLayerBuildingSupport.setupImageLayerArtifacts(imageName);
924+
}
923925
SubstrateTargetDescription target = createTarget();
924926
ImageSingletons.add(Platform.class, loader.platform);
925927
ImageSingletons.add(SubstrateTargetDescription.class, target);

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ public void printCreationEnd(int imageFileSize, int heapObjectCount, long imageH
585585
recordJsonMetric(ImageDetailKey.IMAGE_HEAP_OBJECT_COUNT, heapObjectCount);
586586
Timer imageTimer = getTimer(TimerCollection.Registry.IMAGE);
587587
Timer writeTimer = getTimer(TimerCollection.Registry.WRITE);
588-
stagePrinter.end(imageTimer.getTotalTime() + writeTimer.getTotalTime());
588+
Timer archiveTimer = getTimer(TimerCollection.Registry.ARCHIVE_LAYER);
589+
stagePrinter.end(imageTimer.getTotalTime() + writeTimer.getTotalTime() + archiveTimer.getTotalTime());
589590
creationStageEndCompleted = true;
590591
String format = "%9s (%5.2f%%) for ";
591592
l().a(format, ByteFormattingUtil.bytesToHuman(codeAreaSize), Utils.toPercentage(codeAreaSize, imageFileSize))

0 commit comments

Comments
 (0)