-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
native-image hangs with very high cpu on all threads #1184
Comments
@olpaw commented: @hickst can you try if the following helps: Create an empty subdir and copy the PrettyPrintJSON.class into that directory
Build the image with an explicit -cp argument
With this you should get something like:
|
@hickst I changed the title to indicate that I was not able to reproduce the problem on Linux (as already shown in #1158 (comment)) |
@olpaw Thanks for the idea but it didn't help. native-image starts, it passes the setup stage and just hangs with all threads showing very high usage (see attached screenshot). It never finishes and, after a few minutes, I have to force kill the java process.
|
@hickst do you get the same behavior if you run with
|
Also how much RAM does you machine have? |
My Mac has 128G but your question made me examine the memory issue....so I increased the heap size from 2G to 16G and it successfully compiled the (17 line)
However, the native executable does not work correctly: the JSON is not pretty printed:
Also, this is not just a Mac issue: here's the failure on Ubuntu 16.04, using 2G of heap:
but a successful compilation (albeit in 1:45 minutes) with 16G of heap (out of 32G total memory):
and, again, the program does not pretty print the input JSON:
The issue is very consistent but I cannot discount the possibility that I've installed or configured the GraalVM incorrectly, somehow, on both machines. Do you have any suggestions for what parts of my environment I should check? |
Using the server again shaved 45 seconds off of the build:
and reducing the heap memory to 8G was similarily successful. But, still no luck on the pretty printing:
|
Building an image that contains graaljs with less than 4G for image building is not really a good idea. Image building requires large amounts of memory, especially if you build large images with truffle included. For server-based image building we allow to use 80% of your reported physical RAM for all servers together (keeping max 2 servers alive is currently hardcoded). But never more than 14GB per server (see graal/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java Line 1374 in 556bed6
If you run with --no-server you get the whole 80% of what is reported as physical RAM as baseline. (In this mode additionally provided -Xmx args are respected.)
|
Hmm, the image behaves exactly the same as running PrettyPrintJSON on the JVM:
When running on JVM (via the
when running as native image:
The only difference I can see is that it executes much faster when running as image
vs.
|
Thanks for the clarification: this is all good to know. But, did I miss this requirement documented somewhere in the Getting Started guide? Documentation seems especially important since the maximum heap size (listed by Oracle documentation for Java 8) is "Smaller of 1/4th of the physical memory or 1GB.", which will be insufficient to build the native-image. |
But...but....but it's supposed to actually pretty print the JSON!, as illustrated in the example from the Getting Started guide: |
I just updated to RC16 (on both OSX and Ubuntu) and the issues remain: it takes 2:5+ minutes to build a native image from the 1830 byte |
This is not just building that PrettyPrintJSON class, but includes building a JavaScript engine and the GraalVM compiler when creating that image; so probably more than 10000 classes. We will update the documentation to include heap requirements when adding a dynamic scripting language including compiler to a native image and fix the illustration output to match the program output. |
Thanks, those steps seem reasonable to close this issue. But, I'm still confused....why use a pretty print example if it wasn't intended to really pretty print? |
It does pretty print, just without indentation. If you want indentation, you can specify this as the third parameter to the JSON.stringify method call: We will make sure that output and program exactly matches with respect to pretty printing parameters. |
Ah, I see! Tested and confirmed. Thank-you for promising to fix the documentation so new users like me are no longer confused. :) |
Excellent! Thanks for the report! We will close the issue when the documentation fix is propagated. |
@hickst, please find heap requirements in https://www.graalvm.org/docs/reference-manual/aot-compilation/#prerequisites section. The JSON.stringify method of the example program has been updated too. |
If I try to build the polyglot example (Getting Started/Native Images), the
native-image --language:js PrettyPrintJSON
command gets past the setup phase but then spikes the CPU usage of every thread on the machine to 90+% and never finishes the build:The text was updated successfully, but these errors were encountered: