-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Convert LocalesBuildTimeConfig
to an interface
#39748
Conversation
This comment has been minimized.
This comment has been minimized.
It would appear that converting these config classes to interfaces will eventually mess up the native image metrics that we have defined (number of reflection methods for example). Any thoughts on how to proceed (I guess @zakkak is the one to ask)? |
This comment has been minimized.
This comment has been minimized.
It's not clear to me why this change makes so much difference, I will have a better look and come back. |
My understanding is that the @dmlloyd what's the motivation behind this change? How many more such refactors are planned? The actual impact of this PR can be seen bellow: diff --git a/main/build-2.json b/pr-39748/build-2.json
index aa6d85ccda7..e3dd3aeebbc 100644
--- a/main/build-2.json
+++ b/pr-39748/build-2.json
@@ -2,28 +2,28 @@
"analysis_results": {
"classes": {
"jni": 61,
- "reachable": 20868,
- "reflection": 6715,
- "total": 23665
+ "reachable": 20903,
+ "reflection": 6724,
+ "total": 23696
},
"fields": {
"jni": 61,
- "reachable": 30071,
+ "reachable": 30107,
"reflection": 166,
- "total": 49782
+ "total": 49804
},
"methods": {
"foreign_downcalls": -1,
"jni": 55,
- "reachable": 102966,
- "reflection": 4904,
- "total": 188529
+ "reachable": 103210,
+ "reflection": 5020,
+ "total": 188675
},
"types": {
"jni": 61,
- "reachable": 20868,
- "reflection": 6715,
- "total": 23665
+ "reachable": 20903,
+ "reflection": 6724,
+ "total": 23696
}
},
"general_info": {
@@ -40,36 +40,36 @@
},
"image_details": {
"code_area": {
- "bytes": 44690432,
- "compilation_units": 66895
+ "bytes": 44850784,
+ "compilation_units": 67128
},
"image_heap": {
- "bytes": 48971776,
+ "bytes": 49033216,
"objects": {
- "count": 486768
+ "count": 492441
},
"resources": {
"bytes": 1616272,
"count": 216
}
},
- "total_bytes": 94079808
+ "total_bytes": 94300992
}, These changes are less than 0.3% so it looks like you are being hit by #39674 I suggest updating the image-metrics to make the CI happy. To make this easier I use: #!/bin/bash
KEYS=( \
image_details.total_bytes \
analysis_results.types.reachable \
analysis_results.methods.reachable \
analysis_results.fields.reachable \
analysis_results.types.reflection \
analysis_results.methods.reflection \
analysis_results.fields.reflection \
analysis_results.types.jni \
analysis_results.methods.jni \
analysis_results.fields.jni \
)
echo "# Properties file used by ImageMetricsITCase" > $2
for i in "${KEYS[@]}"
do
echo "$i=$(jq .$i $1)" >> $2
echo "$i.tolerance=3" >> $2
done and run it like this:
|
Hmm, interesting, I would not have expected that to be the case because it is still in the
This is sort of a "canary" PR before starting a broader move away from field-injected config to interface-based config. The reason is that we currently have two different code paths which process configuration, and this is fragile and breaks more often than I would like, so I would like to simplify that. Also, we encourage users to use interface-based config, so we should do the same.
OK. I was worried that I had somehow significantly increased image size, but if we were already on the threshold then I don't feel as bad. Still, it is a bigger impact than I expected for this small change.
OK I'll look into this. |
I don't get why we are suggesting to increase the metrics' threshold. This failure:
Basically says it all. The relative difference in native image size to e7f2a1e would be My reading of this is that the patch results in a size of I.e. Maybe we could rework the patch to not have the bad side effect of increasing the image size yet again? Thoughts? |
We have been discussing this issue a few times with @radcortez and it becomes more pressing to solve given that a lot of config classes got converted to At the moment, the config code very aggressively registers a lot of things for reflection and I'm not entirely sure this is necessary. A comment says this is necessary for Hibernate Validator validation of I did a few experiments with #39778 and it didn't look so bad locally (but I only tested a few modules where I think this is tested). I'll see what CI has to say and report back here. |
I based that on the fact that applying this PR (and only this PR) on top of 18d873e only increases the native image size by less than 0.3% ( and it seems unreasonable to me to gate keep changes for such small increases. I am afraid doing so will become too frustrating especially when the changes are related to how one writes their code instead of actually fetching unnecessary dependencies...
Unfortunately it doesn't, since the
FWIW Applying the PR on top of 18d873e I observed an increase of 216KB, which is still not negligible especially for a change of this kind.
FWIW I have identified some changes with much larger impact that we should probably focus on as a priority, see #39674 (comment).
Wouldn't that mean that we would essentially define this as an "anti-pattern" (assuming I am right in guesstimating what the root cause is) and reverse-patch any occurrences of it? Is this viable? What about other "anti-patterns"?
FYI the additional classes I see being registered for reflection are: 166a167,168
> io.quarkus.runtime.LocalesBuildTimeConfig
> io.quarkus.runtime.LocalesBuildTimeConfig-272116228Impl
316a319
> java.util.Locale
321a325
> java.util.Set Which could explain why more things become reachable, as we are registering all constructors of them. So I was probably wrong in #39748 (comment) regarding buildtime vs runtime initialization. |
We have more - up-to-date - numbers from #39674 which was from a few days ago:
I don't know. At least we should make a conscious decision that we want to go down this route (knowing the effects it has on native image sizes). If we don't we can stop testing using |
@dmlloyd @gsmet I have confirmed that the reflection registrations are to blame for the majority of the metrics increase. Removing them (by hand) and rebuilding gives me the following:
|
So, with my PR, I have the metrics test failing the opposite way:
which is good. BUT I have one test failure related to SmallRye Config and I need to figure out what's going on... |
OK, so it's not looking good. What's interesting is that the rest of Quarkus tests are fine so it might not be entirely necessary for Quarkus config itself but... we might just have been lucky there. I need to discuss this with @radcortez because, from the comment in the code, and our discussions, I think he was under the impression that it was only necessary for Bean Validation support. I thought about avoiding the registration of build time config classes as we wouldn't need them at runtime but either I got unlucky and the extensions didn't have any or they aren't popping up there (I see only runtime and build time and runtime fixed). So I'm not entirely sure what we can do here and we need to discuss this with Roberto. One thing is very clear: in the current state of thing, moving more and more config to |
There are some internal usages of mapping classes in SmallRye Config that are not handled by the build time processor, hence they require runtime introspection. It should be fixable. |
I rebased as I think the work we did with @radcortez might help to get this PR to pass. 🤞 |
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.
@dmlloyd I tested things locally and the metrics issue is fixed. I also added a small commit to restore the default values for documentation (we added an annotation for it when using interfaces).
That being said we still have a failure in io.quarkus.extest.UnknownConfigTest
, which is caused by the unknown property warnings not being logged when you use quarkus.unknown
.
I wonder if using the raw quarkus
prefix doesn't cause an issue.
/cc @radcortez
This comment has been minimized.
This comment has been minimized.
So |
I had a closer look. It's hard to test this locally as apparently even without this patch, I have some failures, which look odd. But this patch leads to the additional inclusion of:
|
This error occurred a few times and looks real:
|
@dmlloyd yes, see this comment: #39748 (review) |
Yes, it seems that it is being caused by this. Let me have a look. |
Not exactly related to that. We collect the root names in the generate |
Status for workflow
|
Status | Name | Step | Failures | Logs | Raw logs | Build scan |
---|---|---|---|---|---|---|
✖ | Native Tests - Data5 | Build |
Failures | Logs | Raw logs | 🔍 |
Full information is available in the Build summary check run.
You can consult the Develocity build scans.
Failures
⚙️ Native Tests - Data5 #
- Failing: integration-tests/jpa-postgresql integration-tests/jpa-postgresql-withxml
📦 integration-tests/jpa-postgresql
✖ io.quarkus.it.jpa.postgresql.ImageMetricsITCase.verifyImageMetrics
line 16
- History - More details - Source on GitHub
org.opentest4j.MultipleFailuresError:
Multiple Failures (1 failure)
org.opentest4j.AssertionFailedError: Expected analysis_results.methods.reflection to be within range [4367 +- 3%] but was 4527 ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:58)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:3012)
at io.quarkus.test.junit.nativeimage.NativeBuildOutputExtension.verifyImageMetrics(NativeBuildOutputExtension.java:59)
at io.quarkus.test.junit.nativeimage.NativeBuildOutputExtension.verifyImageMetrics(NativeBuildOutputExtension.java:46)
📦 integration-tests/jpa-postgresql-withxml
✖ io.quarkus.it.jpa.postgresql.ImageMetricsITCase.verifyImageMetrics
line 15
- History - More details - Source on GitHub
org.opentest4j.MultipleFailuresError:
Multiple Failures (1 failure)
org.opentest4j.AssertionFailedError: Expected analysis_results.methods.reflection to be within range [4551 +- 3%] but was 4710 ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:80)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:58)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:3012)
at io.quarkus.test.junit.nativeimage.NativeBuildOutputExtension.verifyImageMetrics(NativeBuildOutputExtension.java:59)
at io.quarkus.test.junit.nativeimage.NativeBuildOutputExtension.verifyImageMetrics(NativeBuildOutputExtension.java:46)
I have a PR that moves all core configurations to interfaces: #44079. I think we can close this PR and use mine instead. |
No description provided.