1

Today, while profiling a Quarkus app, I found out that io.quarkus.arc.runtime.devconsole.InvocationInterceptor seems to intercept (almost?) all bean classes when Quarkus is running in dev mode, even though the Interceptor has an InterceptorBinding that is not used anywhere in the application code.

@Inherited
@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
public @interface Monitored {
}


@Priority(Interceptor.Priority.LIBRARY_BEFORE)
@Monitored
@Interceptor
public class InvocationInterceptor {
//...
}

Can somebody explain to me why that is the case? I can't really tell if this is intended behaviour or a bug. Is the InterceptorBinding automatically sprinkled around my app during the build? I looked through the code, but could not find a place where that happened.

Why am I interested in that? The bookkeeping this interceptor does uses a CopyOnWriteArrayList (inside Invocation.Builder) which, in a hot loop will quickly generate tens of thousands of copies of that list. Today, that confused the heck out of me while I was profiling the app, because the memory requirements were so drastically different between prod and dev mode.

(If relevant: All of this happened with Quarkus 2.7.3.Final)

Johannes Hahn
  • 363
  • 3
  • 18
  • It is possible for extensions (CDI portable extensions or, in this case, Quarkus extensions) to add interceptor bindings at runtime. I would check the extensions that are active in dev mode! Doesn't the Quarkus console have a tool that gives a view of the CDI model, just to verify that `@Monitored` is applied to your beans? – Nikos Paraskevopoulos Mar 08 '22 at 17:38
  • Yes, I can see the currently active beans with /q/dev/io.quarkus.quarkus-arc/beans. There I can see that the interceptor is added to most, but not all regular bean classes. However, this view does not show the InterceptorBindings (probably assuming that this information can be inferred from the interceptors themselves) – Johannes Hahn Mar 08 '22 at 17:54
  • That is intentional, but there are discussions it should be off by default. In any case, there's a configuration property to switch it off. – Ladicek Mar 08 '22 at 18:08
  • Okay, good to know. Thank you. If you post that as an answer, I will accept it :-) Btw. Do you know where exactly this magic happens? I couldn't find it, but I probably just didn't know where to look... – Johannes Hahn Mar 08 '22 at 18:11

1 Answers1

0

This is essentially @Ladicek's comment:

[The behaviour] is intentional, but there are discussions it should be off by default. In any case, there's a configuration property to switch it off.

I was also able to locate the BuildExtension that does the magic: It is located inside io.quarkus.arc.deployment.devconsole.ArcDevConsoleProcessor.

Johannes Hahn
  • 363
  • 3
  • 18