Skip to content

Commit 2764c87

Browse files
committed
[GR-59474] Refactor timers to account for layer archiving.
PullRequest: graal/19180
2 parents 08df97d + 6bb9314 commit 2764c87

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
@@ -534,14 +534,7 @@ public void run(Map<Method, CEntryPointData> entryPoints,
534534

535535
try (TemporaryBuildDirectoryProviderImpl tempDirectoryProvider = new TemporaryBuildDirectoryProviderImpl()) {
536536
ImageSingletons.add(TemporaryBuildDirectoryProvider.class, tempDirectoryProvider);
537-
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
538-
HostedImageLayerBuildingSupport.setupImageLayerArtifacts(imageName);
539-
}
540537
doRun(entryPoints, javaMainSupport, imageName, k, harnessSubstitutions);
541-
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
542-
ImageSingletonsSupportImpl.HostedManagement.persist();
543-
HostedImageLayerBuildingSupport.singleton().archiveLayer(imageName);
544-
}
545538
} finally {
546539
reporter.ensureCreationStageEndCompleted();
547540
}
@@ -573,7 +566,7 @@ protected void doRun(Map<Method, CEntryPointData> entryPoints, JavaMainSupport j
573566

574567
try (DebugContext debug = new Builder(options, new GraalDebugHandlersFactory(GraalAccess.getOriginalSnippetReflection())).build();
575568
DebugCloseable featureCleanup = () -> featureHandler.forEachFeature(Feature::cleanup)) {
576-
setupNativeImage(options, entryPoints, javaMainSupport, harnessSubstitutions, debug);
569+
setupNativeImage(imageName, options, entryPoints, javaMainSupport, harnessSubstitutions, debug);
577570

578571
boolean returnAfterAnalysis = runPointsToAnalysis(imageName, options, debug);
579572
if (returnAfterAnalysis) {
@@ -766,6 +759,12 @@ protected void doRun(Map<Method, CEntryPointData> entryPoints, JavaMainSupport j
766759
AfterImageWriteAccessImpl afterConfig = new AfterImageWriteAccessImpl(featureHandler, loader, hUniverse, inv, tmpDir, image.getImageKind(), debug);
767760
featureHandler.forEachFeature(feature -> feature.afterImageWrite(afterConfig));
768761
}
762+
try (StopTimer t = TimerCollection.createTimerAndStart(TimerCollection.Registry.ARCHIVE_LAYER)) {
763+
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
764+
ImageSingletonsSupportImpl.HostedManagement.persist();
765+
HostedImageLayerBuildingSupport.singleton().archiveLayer(imageName);
766+
}
767+
}
769768
reporter.printCreationEnd(image.getImageFileSize(), heap.getLayerObjectCount(), image.getImageHeapSize(), codeCache.getCodeAreaSize(), numCompilations, image.getDebugInfoSize());
770769
}
771770
}
@@ -902,10 +901,13 @@ protected boolean verifyAssignableTypes() {
902901
}
903902

904903
@SuppressWarnings("try")
905-
protected void setupNativeImage(OptionValues options, Map<Method, CEntryPointData> entryPoints, JavaMainSupport javaMainSupport,
904+
protected void setupNativeImage(String imageName, OptionValues options, Map<Method, CEntryPointData> entryPoints, JavaMainSupport javaMainSupport,
906905
SubstitutionProcessor harnessSubstitutions, DebugContext debug) {
907906
try (Indent ignored = debug.logAndIndent("setup native-image builder")) {
908907
try (StopTimer ignored1 = TimerCollection.createTimerAndStart(TimerCollection.Registry.SETUP)) {
908+
if (ImageLayerBuildingSupport.buildingSharedLayer()) {
909+
HostedImageLayerBuildingSupport.setupImageLayerArtifacts(imageName);
910+
}
909911
SubstrateTargetDescription target = createTarget();
910912
ImageSingletons.add(Platform.class, loader.platform);
911913
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)