-
Notifications
You must be signed in to change notification settings - Fork 564
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
Heap pressure and OutOfMemory(OOM) when looking up large number of config keys #8767
Comments
Helidon code snippet MpEnvironmentVariablesSource.getValue()
|
To simulate this issue we used following code in the sample app where it uses randomly gerated string as the key. test("Get_Config_with_default_value_test", responseMap, () -> StringUtils.equalsAnyIgnoreCase(config.getString(UUID.randomUUID().toString(), RANDOM), RANDOM)); Heap footprint: Class Name | Objects | Shallow Heap | Retained Heap private final Map<String, Cached> cache = new ConcurrentHashMap<>(); we see that from the heap dump the cache which is implemented as concurrent hashmap in io.helidon.config.mp.MpEnvironmentVariablesSource ended up with ~3M Hash entries with those random keys based on the run from the sample app. some of sample entries below: Key |Value |
we tried out fix with code MpEnvironmentVariablesSource.getValue() modified as follows where as the entries added to cache only if the values exists.
|
Below the code diff: |
we re-ran the same test with above code changes. with this, we no longer see the heap pressure and OOM. non-existing Looked up items are no longer added to the cache. Heap footprint after the code changes: Class Name | Objects | Shallow Heap | Retained Heap io.helidon.config.mp.MpEnvironmentVariablesSource$Cached| 164 | 2,624 | >= 2,624 |
@logovind I understand the issue and the proposed fix, but what is the use case that led you to this OOM? Seems a bit strange to look for all those undefined env variables using config. Could you describe it a bit more? |
Yes, it's bit of negative scenario and not a very common usage pattern However the code path will be executed , for all config parameters , which may have been defined in other sources such config yaml's . For each the env source is checked before other sources, and since those do not exist as env variables ,all those config get added to the cache with null values. |
Issue has been resolved by establishing an upper bound on the cache size and an LRU algorithm. The alternative of not caching certain |
The official fix was tested with 4.1.0 , and. confirmed that bounding the cache avoids the OOM for this scenario, |
Environment Details
Problem Description
we tested Helidon Config with Helidon 4(Version 4.0.8) using sample app. During the test, we found in one of the scenario the sample app continuously look for some config entries. It results in heap growth leading to OOM. checking further we saw the growth is primarily coming from "io.helidon.config.mp.MpEnvironmentVariablesSource". The implementation of this has the cache with concurrent hashmap and all the looked up config items getting added to cache even when environment variable corresponding to the key does not exists.
The text was updated successfully, but these errors were encountered: