-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] Startup time of native compiled with graalvm 20.1-dev is noticably slower than 19.3.0 on macOS #2136
Comments
This does not seem to be the case on linux, so it seems to be mac specific: On linux: 19:
20:
This data was provided to me by @sogaiu. |
@borkdude thanks for your bug report. I will take a look. |
@olpaw I re-tested with the newly released 20.0.0 java8 version, but the problem is still there. If it helps, this is an uberjar of babashka: It is provided which each new release: https://github.com/borkdude/babashka/releases This is the part of the compilation script using that jar:
|
@olpaw Some additional data related to general performance, not only startup time. With 20.0.0-java8 on macOS:
With 19.3.1-java8 on macOS:
That's a 25% loss in performance for v20. |
On linux the performance on version 20-java8 is slightly worse (6%) but not as noticeable as with macOS:
This data was provided by @sogaiu who uses linux. |
Thanks for checking with latest releases! |
Atm, this is my prime subject:
We are now additionally dynamically linking to |
Yep, that's it. If I comment out graal/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJava.java Line 139 in 9a53453
19.3.1 .
While we cannot fully eliminate this dynamic dependency we could make the dependency conditional on actual requirement instead of unconditional linking. @eginez please take this one from here and implement the conditional linking so that we only have to pay for the increased startup time if we actually need it. |
@olpaw That's good news! Is this also the cause of the general performance regression of about 25% on macOS? #2136 (comment) |
@borkdude most likely yes. I only tested with a trivial hello world that does nothing except startup. Your examples with babashka are actually doing a bit of work so pure startup is mixed with actual work that would likely water down the effect of increased startup overhead. |
@olpaw That's true, but the "general performance" I was referring to later was not about startup (although this issue reported that as the first thing and it's already if that can be fixed). A loop with a 1000000 iterations takes 25% longer on macOS 20-java8 (1.98s) than macOS 19.3.1-java8 (1.59s). |
@borkdude tomorrow I will take a look at your bb data by building it locally with the recipe you provide in #2136 (comment) |
@borkdude I cannot reproduce your +25% against master:
where
|
@olpaw That sounds promising. But were you able to reproduce it against the released version 20 java8 macOS? I don't know the relation between the master branch and that release. |
You are right 20.0 binaries are a tad slower
Whatever it was I cannot reproduce on master thus it will be fixed in 20.1. |
Thank you! I'll keep an eye on the dev releases here https://github.com/graalvm/graalvm-ce-dev-builds/releases. |
Yup. Wait for the next |
@olpaw I just realized that the recipe I gave above with the .jar file also requires a reflection.json. I forgot to give you that. In case that may influence the performance, I'll paste it here anyway. I assume you compiled with an empty reflection.json just to make the build work? Maybe also try this one, if it's not too much to ask. |
@olpaw I'm not able to reproduce the "general performance" problem anymore. The reflection.json doesn't seem to have an impact. Compiled with "empty" reflection.json: []
Compiled with full reflection.json:
So please ignore my previous message. I don't know what caused the issue at the time of my initial reproduction of the second issue, I might have been making a mistake somewhere. Sorry to waste your time on the second issue. I'm glad everything is sorted out now. Thanks a lot! |
No worries, I ran a full build with lein (thus I had BTW, if you put your reflection configuration instead into a file named |
@olpaw Alternatively there could be an option |
@olpaw Despite the fix with substitutions in #2136 (comment) I'm now back to where we started with the dev build https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/20.2.0-dev-20200423_0149. When compiling with the new dev-build I'm seeing a startup of around 28ms instead of 13ms and that a lot more dynamic libraries are loaded compared to compiling with 19.3.1: 19.3.1:
Dev build:
Can I prevent this somehow, if I'm not interested in these libraries, to still get good startup time on macOS? Another issue I found is that the binary with the new dev build is around 6MB larger. For what reason? |
We figured out that |
@eginez I'd like to learn more about the reason why this was needed. So far I haven't seen any problems with babashka on 19.3.1 on macOS where the library wasn't loaded. Is it maybe possible to opt out of loading certain dynamic libraries at the cost of errors (on the person who chooses to opt out) to restore startup time in macOS? Adding more dynamic libraries adds tens of milliseconds of startup time, is the end of this in sight? |
To be honest I don't recall any previous change bringing in |
Ok I took some time today to analyze some of the variation. I built
Below the results
Some observations
|
@loicottet can probably expand on the need for 5c5417b. To investigate the size @borkdude I'd like to run a |
Ok I actually ran
@arodionov I know you have been working on this feature, is there something we can do minimize the impact on the image size |
@eginez thanks a lot for investigating! |
Ahh sorry I remember now ... this was driven by the need to generate OSX binaries that do not link against the internal CoreFoundation library. @loicottet implemented that. Its needed for OSX so that the binaries that we produce can be uploaded to AppStore. See #2266 |
Regarding binary sizeIf this is related to XML, then it makes sense. Babashka includes xml functionality, but to do so, I've only added these classes to the reflection config:
How does the XML feature work? Does it automatically detect XML usage and can I now remove these classes from the reflection config for version 20.1 or 20.2? Regarding startup timeThis is what I'm seeing with the latest dev release (https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/20.2.0-dev-20200423_0149) on my system, a Macbook Pro 2019 i9, 32GB ram, macOS mojave 10.14.6:
With 19.3.1:
This is a 12ms startup regression on my system. I'm not planning to deploy my binaries to the AppStore and I would like to opt out of this startup regression if that is possible. |
During the analysis, it detects if there are methods in a call-tree that instantiate XML-parsers via reflection, and registers those parsers. The feature code.
Yes, you can remove reflection config for XML. |
This benchmark uses the last (already optimized) version of the feature. We can try to check maybe some libraries or frameworks also triggers XML-parsers instantiation and substitute those calls. Should have a call-tree for this |
Have checked, during image build, the following parsers are instantiated via methods calls (it means that those methods are present somewhere in a
|
@arodionov Thank you for explaining |
@borkdude as I can see, the most XML-parsers coming via https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgSQLXML.java#L240 |
@arodionov I only recently added support for postgres to babashka, only as of today actually. Try with commit I'm also adding clojure.data.xml to it, so you can do things like this:
so I'm not surprised that XML-related classes are detected, I was only surprised by the difference in binary size between 19.3.1 and 20.1-dev/20.2-dev. |
@borkdude yes, you are right, for the provided commit the following methods bring all XML via:
Most of the XML classes are brought by |
@borkdude in your |
@arodionov Thanks for the advice.
As you can see this fails. But with 20.2-dev this works:
So this explains the extra binary size: there is actually more functionality available now. |
@sogaiu did some measurements and omitting the @eginez @olpaw I think the only unresolved bit in this issue is startup time and dynamically linking. I'll just past that part of the comment here again. This is what I'm seeing with the latest dev release (https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/20.2.0-dev-20200423_0149) on my system, a Macbook Pro 2019 i9, 32GB ram, macOS mojave 10.14.6:
With 19.3.1:
This is a 12ms startup regression on my system. I'm not planning to deploy my binaries to the AppStore and I would like to opt out of this startup regression if that is possible. |
If Apple does not want users to link to CoreFoundation directly we would like to respect that. It would be interesting to see why your measurement results do not seem to match the results from @loicottet as shown on #2266. Maybe a different version of OSX or XCode is responsible for that mismatch. |
|
I don't think so. See #1568 (comment) from @johanvos Relying on linking against non-public symbols sounds like a bad idea to me ... independent from being able to upload native-images to the AppStore. @christianwimmer how should we handle this case? |
@olpaw To be clear, I'm only interested in getting the good startup time on macOS back like it was in 19.3.1. How that is done is an implementation detail to me, but maybe there is not much that can be done? Is the result of loading the public API that 2 more libraries compared to 19.3.1 are being loaded, i.e. the public API loading 2 other libraries (including the private one that was used before)? |
https://github.com/oracle/graal/pull/2266/files#diff-bfc44cccccc87507300243b7d38779bd |
Given a simple class like:
I noticed this when trying out 20.1-dev jdk8 with babashka, a scripting tool made with GraalVM. On GraalVM 19.3.0 java8 it has a startup time of around 14ms, but when I was trying GraalVM 20.1-dev it became 24ms which is 10ms slower.
To build babashka:
Install lein, a Clojure build tool.
Set
GRAALVM_HOME
to either 19 or 20 with java8.Then run
script/compile
(on linux or macos).This will produce a
bb
executable.The text was updated successfully, but these errors were encountered: