-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Improve binding performance when using a large number of property sources #20625
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
Comments
@smaldini Are you able to put together something that replicates the issue? It would be really helpful if we could reproduce this locally so that we can assess the impact of any cache changes we make. |
Also, is it possible to share the flame graph. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
One thing I realized is that we might be doing a double lookup for missing properties. I don't think this is related to the slowness but I was wondering if there is something we can do avoid that. The |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Sorry i didn't look at those notifications - apologies @philwebb @mbhave ! I can't easily provide the flamegraph that showed this but I can try to do a repro case, also the test would be very simple, just a JMH over environment .getProperty with a missed property, vs a property in various locations (first and last). @mbhave suggestion looks good, if we miss in the |
See also #17400 |
Add a test to ensure that a large number of property sources that each contain many items can perform well. See gh-20625
Provide a hashcode implementation for `ConfigurationPropertyName` so that instances can be stored in Map without them all ending up in the same bucket. See gh-20625
Add a `ConfigurationPropertyCaching` utility interface that can be used to control the property source caching. Prior to this commit, a `ConfigurationPropertySource` that was backed by a mutable `EnumerablePropertySource` would need to call the `getPropertyNames()` method each time a property was accessed. Since this this operation can be expensive, we now provide a way to cache the results for a specific length of time. This commit also improves the performance of immutable property sources by limiting the number of candidates that need to be searched. Previously, all mapped names would be enumerated. Now, mappings are grouped by `ConfigurationPropertyName`. This is especially helpful when the `ConfigurationPropertyName` isn't mapped at all since the hash based map lookup will be very fast and the resulting mappings will be empty. Closes spring-projectsgh-20625
Uh oh!
There was an error while loading. Please reload this page.
Hey team !
We have an interesting issue where our propertySource use can be CPU taxing on our systems due to 1/ many propertySources setup (sometimes 80+), 2/ many properties setup over those propertySources (sometimes 1000+).
It seems like the reason is the support for relaxed binding and use of
ConfigurationPropertySourcesPropertySource
in the first position of the list of propertySources although it can be reproduced when "forced" in last position as well. The property resolution is doing a breadth first search of all possible bindings in this layer then it's doing an exact match again a second time. Our flamegraph have revealed a lot of String manipulations happening in hot paths where we useenvironment.getProperty
.In our use cases we use
environment.getProperty
sometimes more than once per request since some properties could have changed. One use case for instance is a dynamic timeout. I imagine any use case with aMutablePropertySource
used in a request or messaging path would reproduce that problem.We are envisioning caching as a possible solution:
The cache could be lazily built or partially (maybe fully?) hydrated on startup if desired although this should be an opt-in given the impact it could have on startup time.
The text was updated successfully, but these errors were encountered: