Skip to content

Commit

Permalink
[GR-33602] [GR-35238] [GR-35714] Additional bugfixes for ProgressRepo…
Browse files Browse the repository at this point in the history
…rter (#3955).

PullRequest: graal/10568
  • Loading branch information
olpaw committed Dec 18, 2021
2 parents e7930bd + d0553d8 commit 5fb00e1
Show file tree
Hide file tree
Showing 17 changed files with 463 additions and 229 deletions.
49 changes: 26 additions & 23 deletions docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,52 @@ permalink: /reference-manual/native-image/BuildOutput/
This page provides documentation for the build output of GraalVM Native Image.

## HelloWorld Example Output
```
```text
================================================================================
GraalVM Native Image: Generating 'helloworld'...
================================================================================
[1/7] Initializing... (2.1s @ 0.19GB)
[1/7] Initializing... (2.5s @ 0.21GB)
Version info: 'GraalVM dev Java 11 CE'
[2/7] Performing analysis... [*******] (5.7s @ 0.47GB)
[2/7] Performing analysis... [*******] (5.6s @ 0.46GB)
2,565 (82.61%) of 3,105 classes reachable
3,216 (60.42%) of 5,323 fields reachable
11,653 (72.44%) of 16,087 methods reachable
11,652 (72.44%) of 16,086 methods reachable
27 classes, 0 fields, and 135 methods registered for reflection
57 classes, 59 fields, and 51 methods registered for JNI access
[3/7] Building universe... (0.4s @ 0.63GB)
[4/7] Parsing methods... [*] (0.4s @ 0.83GB)
[5/7] Inlining methods... [****] (0.4s @ 0.67GB)
[6/7] Compiling methods... [**] (3.4s @ 1.38GB)
[7/7] Creating image... (0.8s @ 1.65GB)
10.52MB in total (35.1% code area, 55.7% image heap, and 9.3% other data)
3.69MB for code area: 6,955 compilation units
5.86MB for image heap: 1,545 classes and 81,111 objects
997.09KB for other data
[3/7] Building universe... (0.5s @ 0.61GB)
[4/7] Parsing methods... [*] (0.5s @ 0.86GB)
[5/7] Inlining methods... [****] (0.5s @ 0.73GB)
[6/7] Compiling methods... [**] (3.7s @ 2.38GB)
[7/7] Creating image... (2.1s @ 1.04GB)
3.69MB (27.19%) for code area: 6,955 compilation units
5.86MB (43.18%) for image heap: 1,545 classes and 80,528 objects
3.05MB (22.46%) for debug info generated in 1.0s
997.25KB ( 7.18%) for other data
13.57MB in total
--------------------------------------------------------------------------------
Top 10 packages in code area: Top 10 object types in image heap:
606.11KB java.util 1.64MB byte[] for general heap data
282.34KB java.lang 718.09KB java.lang.String
606.23KB java.util 1.64MB byte[] for general heap data
282.34KB java.lang 715.56KB java.lang.String
222.47KB java.util.regex 549.46KB java.lang.Class
219.55KB java.text 454.06KB byte[] for java.lang.String
219.55KB java.text 451.79KB byte[] for java.lang.String
193.17KB com.oracle.svm.jni 363.23KB java.util.HashMap$Node
149.80KB java.util.concurrent 192.11KB java.util.HashMap$Node[]
118.09KB java.math 139.04KB char[]
103.60KB com.oracle.svm.core.reflect 136.48KB java.lang.String[]
149.80KB java.util.concurrent 192.00KB java.util.HashMap$Node[]
118.07KB java.math 139.83KB java.lang.String[]
103.60KB com.oracle.svm.core.reflect 139.04KB char[]
97.83KB sun.text.normalizer 130.59KB j.u.c.ConcurrentHashMap$Node
88.78KB c.oracle.svm.core.genscavenge 103.92KB s.u.l.LocaleObjec~e$CacheEntry
... 111 additional packages ... 723 additional object types
(use GraalVM Dashboard to see all)
--------------------------------------------------------------------------------
0.8s (5.4% of total time) in 17 GCs | Peak RSS: 2.60GB | CPU load: ~1183.69%
0.9s (5.6% of total time) in 17 GCs | Peak RSS: 3.22GB | CPU load: 10.87
--------------------------------------------------------------------------------
Produced artifacts:
/home/janedoe/helloworld/helloworld (executable)
/home/janedoe/helloworld/sources (debug_info)
/home/janedoe/helloworld/helloworld (debug_info)
/home/janedoe/helloworld/helloworld.build_artifacts.txt
================================================================================
Finished generating 'helloworld' in 14.0s.
Finished generating 'helloworld' in 16.2s.
```

## Build Stages
Expand Down Expand Up @@ -136,7 +139,7 @@ This data typically contains internal information for Native Image but it can al
### Resource Usage Statistics

#### <a name="glossary-garbage-collection"></a>Garbage Collections
The total time spent in all garbage collectors, total GC time divided by the total time to build the image in percent, and the total number of garbage collections.
The total time spent in all garbage collectors, total GC time divided by the total process time in percent, and the total number of garbage collections.
A large number of collections or time spent in collectors usually indicates that the system is under memory pressure.
Increase the amount of available memory to reduce the time to build the image.

Expand All @@ -146,7 +149,7 @@ This value indicates the maximum amount of memory consumed by the build process.
If the [GC statistics](#glossary-garbage-collection) do not show any problems, the amount of available memory of the system can be reduced to a value closer to the peak RSS.

#### <a name="glossary-cpu-load"></a>CPU load
The CPU time used by the process divided by the total time to build the image in percent.
The CPU time used by the process divided by the total process time.
Increase the number of CPU threads to reduce the time to build the image.

## Build Output Options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.hosted.Feature;

import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.annotate.RecomputeFieldValue;

/**
* This class provides replacement values for the {@link System#in}, {@link System#out}, and
* {@link System#err} streams at run time. We want a fresh set of objects, so that any buffers
Expand All @@ -66,45 +63,32 @@ private static PrintStream newPrintStream(FileOutputStream fos, String enc) {
return new PrintStream(new BufferedOutputStream(fos, 128), true);
}

public InputStream in() {
return in;
}

public static void setIn(InputStream in) {
ImageSingletons.lookup(SystemInOutErrSupport.class).in = Objects.requireNonNull(in);
}

public PrintStream out() {
return out;
}

public static void setOut(PrintStream out) {
ImageSingletons.lookup(SystemInOutErrSupport.class).out = Objects.requireNonNull(out);
}

public static void setErr(PrintStream err) {
ImageSingletons.lookup(SystemInOutErrSupport.class).err = Objects.requireNonNull(err);
public PrintStream err() {
return err;
}

// Checkstyle: stop
Object replaceStreams(Object object) {
if (object == System.in) {
return in;
} else if (object == System.out) {
return out;
} else if (object == System.err) {
return err;
} else {
return object;
}
public static void setErr(PrintStream err) {
ImageSingletons.lookup(SystemInOutErrSupport.class).err = Objects.requireNonNull(err);
}
// Checkstyle: resume
}

/**
* We use an {@link Feature.DuringSetupAccess#registerObjectReplacer object replacer} because the
* streams can be cached in other instance and static fields in addition to the fields in
* {@link System}. We do not know all these places, so we do now know where to place
* {@link RecomputeFieldValue} annotations.
*/
@AutomaticFeature
@SuppressWarnings("unused")
class SystemInOutErrFeature implements Feature {
@Override
public void duringSetup(DuringSetupAccess access) {
SystemInOutErrSupport support = new SystemInOutErrSupport();
ImageSingletons.add(SystemInOutErrSupport.class, support);
access.registerObjectReplacer(support::replaceStreams);
}
/* Dummy for backward compatibility. */
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.compiler.api.runtime.GraalRuntime;
import org.graalvm.compiler.core.common.spi.MetaAccessExtensionProvider;
Expand Down Expand Up @@ -90,6 +89,7 @@
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
import com.oracle.graal.pointsto.util.GraalAccess;
import com.oracle.svm.core.ParsingReason;
import com.oracle.svm.core.SubstrateOptions;
Expand Down Expand Up @@ -121,6 +121,7 @@
import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl;
import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl;
import com.oracle.svm.hosted.NativeImageGenerator;
import com.oracle.svm.hosted.ProgressReporter;
import com.oracle.svm.hosted.analysis.Inflation;
import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport;
import com.oracle.svm.hosted.code.CompilationInfoSupport;
Expand All @@ -133,7 +134,6 @@
import com.oracle.svm.hosted.phases.StrengthenStampsPhase;
import com.oracle.svm.hosted.phases.SubstrateClassInitializationPlugin;
import com.oracle.svm.hosted.phases.SubstrateGraphBuilderPhase;
import com.oracle.svm.hosted.reporting.ProgressReporter;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;

import jdk.vm.ci.meta.DeoptimizationAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
import java.util.function.BooleanSupplier;
import java.util.stream.Collectors;

import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.meta.PointsToAnalysisFactory;
import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
import org.graalvm.collections.EconomicSet;
import org.graalvm.collections.Pair;
import org.graalvm.compiler.api.replacements.Fold;
Expand Down Expand Up @@ -135,6 +132,7 @@
import com.oracle.graal.pointsto.BigBang;
import com.oracle.graal.pointsto.BytecodeSensitiveAnalysisPolicy;
import com.oracle.graal.pointsto.DefaultAnalysisPolicy;
import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.api.PointstoOptions;
import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException;
import com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor;
Expand All @@ -146,6 +144,8 @@
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.meta.PointsToAnalysisFactory;
import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
import com.oracle.graal.pointsto.reports.AnalysisReporter;
import com.oracle.graal.pointsto.typestate.TypeState;
import com.oracle.graal.pointsto.util.AnalysisError;
Expand Down Expand Up @@ -220,6 +220,7 @@
import com.oracle.svm.hosted.FeatureImpl.BeforeUniverseBuildingAccessImpl;
import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl;
import com.oracle.svm.hosted.FeatureImpl.OnAnalysisExitAccessImpl;
import com.oracle.svm.hosted.ProgressReporter.ReporterClosable;
import com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider;
import com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider;
import com.oracle.svm.hosted.analysis.Inflation;
Expand Down Expand Up @@ -270,8 +271,6 @@
import com.oracle.svm.hosted.phases.SubstrateClassInitializationPlugin;
import com.oracle.svm.hosted.phases.VerifyDeoptFrameStatesLIRPhase;
import com.oracle.svm.hosted.phases.VerifyNoGuardsPhase;
import com.oracle.svm.hosted.reporting.ProgressReporter;
import com.oracle.svm.hosted.reporting.ProgressReporter.ReporterClosable;
import com.oracle.svm.hosted.snippets.SubstrateGraphBuilderPlugins;
import com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor;
import com.oracle.svm.hosted.substitute.DeletedFieldsPlugin;
Expand Down Expand Up @@ -680,7 +679,7 @@ private void doRun(Map<Method, CEntryPointData> 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());
}
Expand Down
Loading

0 comments on commit 5fb00e1

Please sign in to comment.