Optimize CacheKey handling in SpringIterableConfigurationPropertySource #16717
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
as described in #16401 there is an optimization opportunity in
SpringIterableConfigurationPropertySource
when checking for CacheKey equality. Currently, for large Sets this takes a considerable amount of time as the two Sets are usually equal, but not the same instance. This is due to the fact that the internal key inside CacheKey is copied in order to fix #13344 and can thus not benefit from a==
comparison.The idea of this PR is to introduce a flag that effectively disables the copying of the internal key under certain circumstances. Imho, this could be done for
OriginTrackedMapPropertySource
instances which is used to load either.yaml
or.properties
files, which usually shouldn't be a subject of change (and even if require a refresh of some sort). I still implemented an additional check for the size of the internal key in a best effort to track key additions at least forOriginTrackedMapPropertySource
s, too.With the applied changes, I see major improvements compared to a M2 baseline.
Let me know what you think.
Cheers,
Christoph