-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
ArC - remove unused interceptors #18970
Conversation
mkouba
commented
Jul 23, 2021
- and beans injected only by these interceptors
- and beans that are only injected in removed beans
Things to add:
|
Awesome! |
42a7462
to
431b064
Compare
This workflow status is outdated as a new workflow run has been triggered. Failing Jobs - Building 431b064
Full information is available in the Build summary check run. Test Failures⚙️ JVM Tests - JDK 11 #📦 extensions/mailer/deployment✖
✖
📦 extensions/smallrye-fault-tolerance/deployment✖
⚙️ JVM Tests - JDK 11 Windows #📦 extensions/mailer/deployment✖
✖
📦 extensions/smallrye-fault-tolerance/deployment✖
⚙️ JVM Tests - JDK 16 #📦 extensions/mailer/deployment✖
✖
📦 extensions/smallrye-fault-tolerance/deployment✖
⚙️ Native Tests - Cache #📦 integration-tests/cache✖
⚙️ Native Tests - Data4 #📦 integration-tests/mongodb-panache-kotlin✖
✖
✖
✖
✖
✖
|
431b064
to
16fcd22
Compare
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java
Outdated
Show resolved
Hide resolved
Looks good to me, but my knowledge of ArC is very superficial. Regarding the algorithm: I guess it's a best effort, to be really sure to remove it all it should run in multiple phases until it neither any bean nor any interceptor is removed, no? Also wondering: would you want to merge this now, or rather wait for 2.3+ ? |
Looks fine on the first sight, though I'd have to check it out locally and walk around the code for a few hours to be confident :-) @Sanne I think this method Lines 386 to 421 in 16fcd22
|
Ah I probably got it wrong. Indeed currently removing unused interceptors/decorators is only a single pass, which is followed by removing unused beans (which is iterated). I don't really know if it's possible for unused beans to declare interceptors that would become unused after the unused beans are removed, but I guess it might. |
Right, I think (if we wanted to really cover it all) something similar would need to be done while taking into account both beans and interceptors. But I'm not sure if it's worth it - both in terms of complexity/maintenance and in terms of complexity/execution times. Was just bringing it up as I'm curious if it was a conscious choice. |
OK, even better. So we remove unused beans at the beginning, then remove unused interceptors/decorators (that's single pass), then we remove unused beans again. I think it should be something like this instead (pseudocode): boolean shouldContinue = true;
while (shouldContinue) {
boolean someBeansRemoved = removeUnusedBeans(...);
boolean someInterceptorsRemoved = removeUnusedInterceptors(...);
boolean someDecoratorsRemoved = removeUnusedDecorators(...);
shouldContinue = someBeansRemoved || someInterceptorsRemoved || someDecoratorsRemoved;
} |
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'll approve so that @mkouba can merge if he wants to 👍
I'd be keen to measure it but my pet projects don't really use interceptors so I won't do this yet. I might do another pass to measure additional memory costs in ArcContainerImpl
, but I do those in batches later.
Yes, I think that in theory it's possible. For example if you have a bean
That's a good question. It should probably target 2.3 because we may expect problems with programmatic lookup in extensions that do rely on less strict implementation (although the rules stay the same ;-).
Yes, it's a best effort. But we should probably try to cover maximum use cases... |
Moving the fixed point iteration up one level shouldn't be hard, from my superficial understanding of the code. If @mkouba doesn't get to it, I may try later :-) |
I'm on it but I'll ping you for review ;-) |
This workflow status is outdated as a new workflow run has been triggered. Failing Jobs - Building 16fcd22
Full information is available in the Build summary check run. Test Failures⚙️ JVM Tests - JDK 11 #📦 extensions/resteasy-classic/rest-client/deployment✖
✖
⚙️ JVM Tests - JDK 11 Windows #📦 extensions/resteasy-classic/rest-client/deployment✖
✖
⚙️ JVM Tests - JDK 16 #📦 extensions/resteasy-classic/rest-client/deployment✖
✖
⚙️ Native Tests - Cache #📦 integration-tests/cache✖
⚙️ Native Tests - Data4 #📦 integration-tests/mongodb-panache-kotlin✖
✖
✖
✖
✖
✖
|
16fcd22
to
d210858
Compare
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.
LGTM. My understanding of ArC internals is very shallow, so this is mostly a general approval, not rubber stamping of all the specific details :-)
Don't be afraid I will not blame you if we find a critical bug in the relevant part of the code... or will I? ;-) |
This workflow status is outdated as a new workflow run has been triggered. Failing Jobs - Building 2de5b0c
Full information is available in the Build summary check run. Test Failures⚙️ JVM Tests - JDK 11 #📦 integration-tests/smallrye-config✖
✖
✖
✖
📦 integration-tests/smallrye-opentracing✖
⚙️ JVM Tests - JDK 11 Windows #📦 integration-tests/smallrye-config✖
✖
✖
✖
✖
📦 integration-tests/smallrye-opentracing✖
⚙️ JVM Tests - JDK 16 #📦 extensions/resteasy-reactive/rest-client-reactive/deployment✖
📦 integration-tests/smallrye-config✖
✖
✖
✖
📦 integration-tests/smallrye-opentracing✖
|
All CI jobs are green except for
I don't think it's related so I'm going to rebase and squash all commits. |
9e34937
to
13fc068
Compare
It is not related. It's some race condition that I yet to track down |
This workflow status is outdated as a new workflow run has been triggered. Failing Jobs - Building 13fc068
Full information is available in the Build summary check run. Test Failures⚙️ MicroProfile TCKs Tests #📦 tcks/microprofile-fault-tolerance✖
|
@Ladicek Just out of curiosity - have you ever seen this ^ |
@mkouba Yea that's flaky (smallrye/smallrye-fault-tolerance#233), but it seems to only occur in Quarkus :-) I've never seen it in SRye Fault Tolerance CI. |
Ok, so this PR is ready but should probably wait until the main branch corresponds to 2.3. @gsmet WDYT? |
13fc068
to
4d41128
Compare
OTOH according to the release planning this PR would have to wait at least few weeks, which is acceptable but may cause headaches while resolving conflicts ;-). |
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.
Let's wait for 2.3. Please dismiss once 2.2 is merged.
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.
Let's wait for 2.3. Please dismiss once 2.2 is branched.
4d41128
to
d9b73b1
Compare
This workflow status is outdated as a new workflow run has been triggered. Failing Jobs - Building d9b73b1
|
- and beans injected only by these interceptors and decorators - and beans that are only injected in removed beans - log the full stack trace if DEBUG level is enabled - fix JTA and SR CP integration - - the tx manager is obtained via CDI.current().select(TransactionManager.class) in the JtaContextProvider - fix SmallRye Metrics - MetricRegistries must be unremovable - fix cache and rest-client integration - fix SmallRye OpenTracing - make any bean that has io.opentracing.Tracer in bean types unremovable - update the docs
d9b73b1
to
c547606
Compare
I've also prepared a short blogpost about this optimization: https://github.com/mkouba/quarkusio.github.io-1/tree/unused-beans-next |