Skip to content

[GR-62002] [Native Image] System.getProperties evaluates all Lazy expensive values #10630

@radcortez

Description

@radcortez

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 by System, but this is far from ideal: quarkusio/quarkus#45997

I'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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions