Various assorted performance improvements#1486
Open
gsmet wants to merge 5 commits intosmallrye:mainfrom
Open
Conversation
Instead of iterating through all property names, the createRequired() method now uses the index to only examine properties with the relevant prefix.
PropertyName hashCode() is not designed for being used in an HashSet/HashMap so we should avoid it at all costs. It is both inefficient when populating the HashSet/HashMap and when getting the elements from it. Also fixes substring calculation for .** patterns (it was dropping the dot, which we actually want to keep).
Identifying prefixing that we ignore from the get go allows to filter things a lot more efficiently and avoid populating filters with elements that we will in any case not consider because of the ignored prefixes. This reduces the population cost and also the interrogation cost.
Check if secretKeys is empty before calling contains() to avoid unnecessary allocations and hash lookups when there are no secret keys configured. Note that again we shouldn't use a HashSet to store PropertyNames for secret keys and that's something that IMHO requires a more global fix. Also don't enter complex logic to match [ if there's no [ in the property name.
gsmet
commented
Mar 11, 2026
Comment on lines
+152
to
+183
| private void buildPropertyPrefixIndex() { | ||
| for (String propertyName : config.getPropertyNames()) { | ||
| // Index by all prefixes: "foo.bar.baz" -> index under "foo", "foo.bar", "foo.bar.baz" | ||
| // Also handle indexed properties: "foo.bar[0]" -> index under "foo", "foo.bar" | ||
| int dotIndex = 0; | ||
| int lastDotIndex = -1; | ||
| while (dotIndex < propertyName.length()) { | ||
| dotIndex = propertyName.indexOf('.', dotIndex); | ||
| if (dotIndex == -1) { | ||
| // No more dots - check if there's a bracket in the last segment | ||
| int searchStart = lastDotIndex + 1; | ||
| int bracketIndex = propertyName.indexOf('[', searchStart); | ||
| if (bracketIndex != -1) { | ||
| // Index under the part before the bracket: "foo.bar[0]" -> index under "foo.bar" | ||
| String prefixBeforeBracket = propertyName.substring(0, bracketIndex); | ||
| propertyPrefixIndex.computeIfAbsent(prefixBeforeBracket, k -> new HashSet<>()) | ||
| .add(propertyName); | ||
| } else { | ||
| // No bracket in last segment - index under the full property name | ||
| propertyPrefixIndex.computeIfAbsent(propertyName, k -> new HashSet<>()) | ||
| .add(propertyName); | ||
| } | ||
| break; | ||
| } | ||
| String prefix = propertyName.substring(0, dotIndex); | ||
| propertyPrefixIndex.computeIfAbsent(prefix, k -> new HashSet<>()) | ||
| .add(propertyName); | ||
| lastDotIndex = dotIndex; | ||
| dotIndex++; | ||
| } | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
FWIW, I'm not entirely sure this is completely correct from a functional point of view. Tests are passing but it needs better scrutiny from someone from the project :).
gsmet
commented
Mar 11, 2026
Comment on lines
-201
to
+250
| ignoredPrefixes.add(ignoredPath.substring(0, ignoredPath.length() - 3)); | ||
| ignoredPrefixes.add(ignoredPath.substring(0, ignoredPath.length() - 2)); |
Contributor
Author
There was a problem hiding this comment.
This change is actually a bugfix. We need to keep the dot at the end of the prefix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
See individual commit comments for the details.
Note that I think we really need to review all the places where
PropertyNameis used in aHashSetorHashMapand either use a more sophisticated approach for matching or useListinstead as, in the end, it's better to use aListthan aHashSet/HashMap.I think this work is a good first step and ^ requires more SmallRye Config expertise.