-
Notifications
You must be signed in to change notification settings - Fork 3k
Cache nested mapping implementations #48549
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
Cache nested mapping implementations #48549
Conversation
This comment has been minimized.
This comment has been minimized.
Class<?> klass = Thread.currentThread().getContextClassLoader().loadClass(mappingClass); | ||
return ConfigClass.configClass(klass, prefix); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm correct that no changes were made here? You just split the call in two lines.
How exactly do we leverage the cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was to make the call more visible, since this is only required to support non-public classes.
The cache is in SR Config:
https://github.com/smallrye/smallrye-config/blob/60923e71855c9f129132aab305a7dd168f219ed6/implementation/src/main/java/io/smallrye/config/ConfigMappingLoader.java#L25-L30
With a MethodHandle
for the constructor:
https://github.com/smallrye/smallrye-config/blob/60923e71855c9f129132aab305a7dd168f219ed6/implementation/src/main/java/io/smallrye/config/ConfigMappingLoader.java#L172-L202
Which is used to construct the main mapping and each nested element:
https://github.com/smallrye/smallrye-config/blob/60923e71855c9f129132aab305a7dd168f219ed6/implementation/src/main/java/io/smallrye/config/ConfigMappingLoader.java#L87-L108
I had an idea some time ago that I could generate the constructors' bytecode for nested elements, which would improve this a bit more, but I don't have that yet.
Unfortunately, this now conflicts with |
03265e4
to
bf79e24
Compare
Was just imports. |
Status for workflow
|
This will reduce runtime operations in the native image by caching nested mapped implementation handles in a static block.