-
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
[GR-62002] [Native Image] System.getProperties
evaluates all Lazy expensive values
#10630
Comments
Hi radcortez, |
Yes, it also happens in the latest version. If you notice, the main code is initializing all the System properties: This method is used as a Substitution for |
System.getProperties
evaluates all Lazy expensive valuesSystem.getProperties
evaluates all Lazy expensive values
We will take a closer look into this and I'll make sure to keep you updated. Thank you. |
Thanks! |
@radcortez : is the difference still measurable now that #10613 was merged? |
I'll try, but I believe so by looking into the code: Getting the And the substitution: |
Thanks! Yes, getting the |
I'll give it a try. Regardless, shouldn't we have a way to get a list of the property names without incurring the initialization cost? Thank you. |
Describe the Issue
In Quarkus, to populate certain pieces of the configuration, we need to look up the available names in multiple sources (System, ENV, etc.).
The only way to retrieve the list of names coming from System properties is by calling
System.getProperties()
, and then either iterate the keys or call.propertyNames
,stringPropertyNames
.Unfortunately, this means that we always have to pay the price of the expensive computation of the lazy values implemented in the substitution here: https://github.com/oracle/graal/blob/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java#L209-L212
We do measure a 5-6 ms startup time in our environments, which we would like to avoid since we don't need the values at all, and just the available names set by System properties. We did workaround the issue by adding a substitution in the entire
Properties
returned bySystem
, but this is far from ideal: quarkusio/quarkus#45997I'm happy to work and submit a PR with an agreement on what the solution could be.
Using the latest version of GraalVM can resolve many issues.
GraalVM Version
java 21.0.5 2024-10-15 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.5+9.1 (build 21.0.5+9-LTS-jvmci-23.1-b48)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.5+9.1 (build 21.0.5+9-LTS-jvmci-23.1-b48, mixed mode, sharing)
Operating System and Version
Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64 x86_64
Troubleshooting Confirmation
Run Command
NA
Expected Behavior
Have a way to call
System.getProperties
and the list of names without incurring the penalty cost of evaluating the lazy values.Actual Behavior
NA
Steps to Reproduce
NA
Additional Context
No response
Run-Time Log Output and Error Messages
No response
The text was updated successfully, but these errors were encountered: