Skip to content

Commit

Permalink
Add details about app resources to build output.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed May 16, 2022
1 parent 340293c commit 5e652cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 5 additions & 2 deletions docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ GraalVM Native Image: Generating 'helloworld' (executable)...
[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: 80,528 objects
5.86MB (43.18%) for image heap: 80,528 objects and 5 resources
3.05MB (22.46%) for debug info generated in 1.0s
997.25KB ( 7.18%) for other data
13.57MB in total
Expand Down Expand Up @@ -133,12 +133,15 @@ The code area contains machine code produced by the Graal compiler for all reach
Therefore, reducing the number of [reachable methods](#glossary-reachability) also reduces the size of the code area.
#### <a name="glossary-image-heap"></a>Image Heap
The image heap contains reachable objects such as static application data, metadata, and `byte[]` for different purposes.
The image heap contains reachable objects such as static application data, metadata, and `byte[]` for different purposes (see below).
##### <a name="glossary-general-heap-data"></a>General Heap Data Stored in `byte[]`
The total size of all `byte[]` objects that are neither used for `java.lang.String`, nor [code metadata](#glossary-code-metadata), nor [reflection metadata](#glossary-reflection-metadata), nor [graph encodings](#glossary-graph-encodings).
Therefore, this can also include `byte[]` objects from application code.
##### <a name="glossary-embedded-resources"></a>Embedded Resources Stored in `byte[]`
The total size of all `byte[]` objects used for storing resources (e.g., files accessed via `Class.getResource()`) within the native image. The number of resources is shown in the [Image Heap](#glossary-image-heap) section.
##### <a name="glossary-code-metadata"></a>Code Metadata Stored in `byte[]`
The total size of all `byte[]` objects used for metadata for the [code area](#glossary-code-area).
Therefore, reducing the number of [reachable methods](#glossary-reachability) also reduces the size of this metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.code.CodeInfoTable;
import com.oracle.svm.core.heap.Heap;
import com.oracle.svm.core.jdk.Resources;
import com.oracle.svm.core.jdk.resources.ResourceStorageEntry;
import com.oracle.svm.core.option.HostedOptionValues;
import com.oracle.svm.core.reflect.ReflectionMetadataDecoder;
import com.oracle.svm.core.util.VMError;
Expand Down Expand Up @@ -389,8 +391,9 @@ public void printCreationEnd(int imageSize, int numHeapObjects, long imageHeapSi
String format = "%9s (%5.2f%%) for ";
l().a(format, Utils.bytesToHuman(codeCacheSize), codeCacheSize / (double) imageSize * 100)
.doclink("code area", "#glossary-code-area").a(":%,9d compilation units", numCompilations).println();
int numResources = Resources.singleton().resources().size();
l().a(format, Utils.bytesToHuman(imageHeapSize), imageHeapSize / (double) imageSize * 100)
.doclink("image heap", "#glossary-image-heap").a(": %,8d objects", numHeapObjects).println();
.doclink("image heap", "#glossary-image-heap").a(":%,8d objects and %,d resources", numHeapObjects, numResources).println();
if (debugInfoSize > 0) {
DirectPrinter l = l().a(format, Utils.bytesToHuman(debugInfoSize), debugInfoSize / (double) imageSize * 100)
.doclink("debug info", "#glossary-debug-info");
Expand Down Expand Up @@ -502,6 +505,16 @@ private Map<String, Long> calculateHeapBreakdown(Collection<ObjectInfo> heapObje
classNameToSize.put(BREAKDOWN_BYTE_ARRAY_PREFIX + linkStrategy.asDocLink("reflection metadata", "#glossary-reflection-metadata"), metadataByteLength);
remainingBytes -= metadataByteLength;
}
long resourcesByteLength = 0;
for (ResourceStorageEntry resourceList : Resources.singleton().resources().getValues()) {
for (byte[] resource : resourceList.getData()) {
resourcesByteLength += resource.length;
}
}
if (resourcesByteLength > 0) {
classNameToSize.put(BREAKDOWN_BYTE_ARRAY_PREFIX + linkStrategy.asDocLink("embedded resources", "#glossary-embedded-resources"), resourcesByteLength);
remainingBytes -= resourcesByteLength;
}
if (graphEncodingByteLength > 0) {
classNameToSize.put(BREAKDOWN_BYTE_ARRAY_PREFIX + linkStrategy.asDocLink("graph encodings", "#glossary-graph-encodings"), graphEncodingByteLength);
remainingBytes -= graphEncodingByteLength;
Expand Down

0 comments on commit 5e652cd

Please sign in to comment.