64
64
import com .oracle .svm .common .option .CommonOptionParser ;
65
65
import com .oracle .svm .core .BuildArtifacts ;
66
66
import com .oracle .svm .core .BuildArtifacts .ArtifactType ;
67
+ import com .oracle .svm .core .ByteUtil ;
67
68
import com .oracle .svm .core .SubstrateGCOptions ;
68
69
import com .oracle .svm .core .SubstrateOptions ;
69
70
import com .oracle .svm .core .SubstrateUtil ;
@@ -251,7 +252,7 @@ public void printInitializeEnd(List<Feature> features, ImageClassLoader classLoa
251
252
String gcName = Heap .getHeap ().getGC ().getName ();
252
253
recordJsonMetric (GeneralInfo .GC , gcName );
253
254
long maxHeapSize = SubstrateGCOptions .MaxHeapSize .getValue ();
254
- String maxHeapValue = maxHeapSize == 0 ? Heap .getHeap ().getGC ().getDefaultMaxHeapSize () : ByteFormattingUtil .bytesToHuman (maxHeapSize );
255
+ String maxHeapValue = maxHeapSize == 0 ? Heap .getHeap ().getGC ().getDefaultMaxHeapSize () : ByteUtil .bytesToHuman (maxHeapSize );
255
256
l ().a (" " ).doclink ("Garbage collector" , "#glossary-gc" ).a (": " ).a (gcName ).a (" (" ).doclink ("max heap size" , "#glossary-gc-max-heap-size" ).a (": " ).a (maxHeapValue ).a (")" ).println ();
256
257
257
258
printFeatures (features );
@@ -447,7 +448,7 @@ private void printResourceInfo() {
447
448
448
449
l ().printLineSeparator ();
449
450
l ().yellowBold ().doclink ("Build resources" , "#glossary-build-resources" ).a (":" ).reset ().println ();
450
- l ().a (" - %.2fGB of memory (%.1f%% of system memory, reason: %s)" , ByteFormattingUtil . bytesToGiB (maxMemory ), Utils .toPercentage (maxMemory , totalMemorySize ), memoryUsageReason ).println ();
451
+ l ().a (" - %.2fGB of memory (%.1f%% of system memory, reason: %s)" , ByteUtil . bytesToGB (maxMemory ), Utils .toPercentage (maxMemory , totalMemorySize ), memoryUsageReason ).println ();
451
452
l ().a (" - %s thread(s) (%.1f%% of %s available processor(s), %s)" ,
452
453
maxNumberOfThreads , Utils .toPercentage (maxNumberOfThreads , availableProcessors ), availableProcessors , maxNumberOfThreadsSuffix ).println ();
453
454
}
@@ -591,15 +592,15 @@ public void printCreationEnd(int imageFileSize, int heapObjectCount, long imageH
591
592
stagePrinter .end (imageTimer .getTotalTime () + writeTimer .getTotalTime () + archiveTimer .getTotalTime ());
592
593
creationStageEndCompleted = true ;
593
594
String format = "%9s (%5.2f%%) for " ;
594
- l ().a (format , ByteFormattingUtil .bytesToHuman (codeAreaSize ), Utils .toPercentage (codeAreaSize , imageFileSize ))
595
+ l ().a (format , ByteUtil .bytesToHuman (codeAreaSize ), Utils .toPercentage (codeAreaSize , imageFileSize ))
595
596
.doclink ("code area" , "#glossary-code-area" ).a (":%,10d compilation units" , numCompilations ).println ();
596
597
int numResources = Resources .singleton ().count ();
597
598
recordJsonMetric (ImageDetailKey .IMAGE_HEAP_RESOURCE_COUNT , numResources );
598
- l ().a (format , ByteFormattingUtil .bytesToHuman (imageHeapSize ), Utils .toPercentage (imageHeapSize , imageFileSize ))
599
+ l ().a (format , ByteUtil .bytesToHuman (imageHeapSize ), Utils .toPercentage (imageHeapSize , imageFileSize ))
599
600
.doclink ("image heap" , "#glossary-image-heap" ).a (":%,9d objects and %,d resources" , heapObjectCount , numResources ).println ();
600
601
if (debugInfoSize > 0 ) {
601
602
recordJsonMetric (ImageDetailKey .DEBUG_INFO_SIZE , debugInfoSize ); // Optional metric
602
- DirectPrinter l = l ().a (format , ByteFormattingUtil .bytesToHuman (debugInfoSize ), Utils .toPercentage (debugInfoSize , imageFileSize ))
603
+ DirectPrinter l = l ().a (format , ByteUtil .bytesToHuman (debugInfoSize ), Utils .toPercentage (debugInfoSize , imageFileSize ))
603
604
604
605
.doclink ("debug info" , "#glossary-debug-info" );
605
606
if (debugInfoTimer != null ) {
@@ -612,9 +613,9 @@ public void printCreationEnd(int imageFileSize, int heapObjectCount, long imageH
612
613
recordJsonMetric (ImageDetailKey .TOTAL_SIZE , imageFileSize );
613
614
recordJsonMetric (ImageDetailKey .CODE_AREA_SIZE , codeAreaSize );
614
615
recordJsonMetric (ImageDetailKey .NUM_COMP_UNITS , numCompilations );
615
- l ().a (format , ByteFormattingUtil .bytesToHuman (otherBytes ), Utils .toPercentage (otherBytes , imageFileSize ))
616
+ l ().a (format , ByteUtil .bytesToHuman (otherBytes ), Utils .toPercentage (otherBytes , imageFileSize ))
616
617
.doclink ("other data" , "#glossary-other-data" ).println ();
617
- l ().a ("%9s in total" , ByteFormattingUtil .bytesToHuman (imageFileSize )).println ();
618
+ l ().a ("%9s in total" , ByteUtil .bytesToHuman (imageFileSize )).println ();
618
619
printBreakdowns ();
619
620
ImageSingletons .lookup (ProgressReporterFeature .class ).afterBreakdowns ();
620
621
printRecommendations ();
@@ -652,7 +653,7 @@ private void printBreakdowns() {
652
653
if (packagesBySize .hasNext ()) {
653
654
Entry <String , Long > e = packagesBySize .next ();
654
655
String className = Utils .truncateClassOrPackageName (e .getKey ());
655
- codeSizePart = String .format ("%9s %s" , ByteFormattingUtil .bytesToHuman (e .getValue ()), className );
656
+ codeSizePart = String .format ("%9s %s" , ByteUtil .bytesToHuman (e .getValue ()), className );
656
657
printedCodeBytes += e .getValue ();
657
658
printedCodeItems ++;
658
659
}
@@ -666,7 +667,7 @@ private void printBreakdowns() {
666
667
className = Utils .truncateClassOrPackageName (className );
667
668
}
668
669
long byteSize = e .byteSize ;
669
- heapSizePart = String .format ("%9s %s" , ByteFormattingUtil .bytesToHuman (byteSize ), className );
670
+ heapSizePart = String .format ("%9s %s" , ByteUtil .bytesToHuman (byteSize ), className );
670
671
printedHeapBytes += byteSize ;
671
672
printedHeapItems ++;
672
673
}
@@ -680,9 +681,9 @@ private void printBreakdowns() {
680
681
int numHeapItems = heapBreakdown .getSortedBreakdownEntries ().size ();
681
682
long totalCodeBytes = codeBreakdown .values ().stream ().mapToLong (Long ::longValue ).sum ();
682
683
683
- p .l ().a (String .format ("%9s for %s more packages" , ByteFormattingUtil .bytesToHuman (totalCodeBytes - printedCodeBytes ), numCodeItems - printedCodeItems ))
684
+ p .l ().a (String .format ("%9s for %s more packages" , ByteUtil .bytesToHuman (totalCodeBytes - printedCodeBytes ), numCodeItems - printedCodeItems ))
684
685
.jumpToMiddle ()
685
- .a (String .format ("%9s for %s more object types" , ByteFormattingUtil .bytesToHuman (heapBreakdown .getTotalHeapSize () - printedHeapBytes ), numHeapItems - printedHeapItems ))
686
+ .a (String .format ("%9s for %s more object types" , ByteUtil .bytesToHuman (heapBreakdown .getTotalHeapSize () - printedHeapBytes ), numHeapItems - printedHeapItems ))
686
687
.flushln ();
687
688
}
688
689
@@ -838,7 +839,7 @@ private void printResourceStatistics() {
838
839
.doclink ("GCs" , "#glossary-garbage-collections" );
839
840
long peakRSS = ProgressReporterCHelper .getPeakRSS ();
840
841
if (peakRSS >= 0 ) {
841
- p .a (" | " ).doclink ("Peak RSS" , "#glossary-peak-rss" ).a (": " ).a ("%.2fGB" , ByteFormattingUtil . bytesToGiB (peakRSS ));
842
+ p .a (" | " ).doclink ("Peak RSS" , "#glossary-peak-rss" ).a (": " ).a ("%.2fGB" , ByteUtil . bytesToGB (peakRSS ));
842
843
}
843
844
recordJsonMetric (ResourceUsageKey .PEAK_RSS , (peakRSS >= 0 ? peakRSS : UNAVAILABLE_METRIC ));
844
845
long processCPUTime = getOperatingSystemMXBean ().getProcessCpuTime ();
@@ -863,7 +864,7 @@ private void checkForExcessiveGarbageCollection() {
863
864
.a (": %.1fs spent in %d GCs during the last stage, taking up %.2f%% of the time." ,
864
865
Utils .millisToSeconds (gcTimeDeltaMillis ), currentGCStats .totalCount - lastGCStats .totalCount , ratio * 100 )
865
866
.println ();
866
- l ().a (" Please ensure more than %.2fGB of memory is available for Native Image" , ByteFormattingUtil . bytesToGiB (ProgressReporterCHelper .getPeakRSS ())).println ();
867
+ l ().a (" Please ensure more than %s of memory is available for Native Image" , ByteUtil . bytesToHuman (ProgressReporterCHelper .getPeakRSS ())).println ();
867
868
l ().a (" to reduce GC overhead and improve image build time." ).println ();
868
869
}
869
870
lastGCStats = currentGCStats ;
@@ -900,7 +901,7 @@ private static double nanosToSeconds(double nanos) {
900
901
}
901
902
902
903
private static double getUsedMemory () {
903
- return ByteFormattingUtil . bytesToGiB (Runtime .getRuntime ().totalMemory () - Runtime .getRuntime ().freeMemory ());
904
+ return ByteUtil . bytesToGB (Runtime .getRuntime ().totalMemory () - Runtime .getRuntime ().freeMemory ());
904
905
}
905
906
906
907
private static String stringFilledWith (int size , String fill ) {
0 commit comments