You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Jonathan Gallimore <jo...@gmail.com> on 2022/11/17 11:19:45 UTC

TOMEE-4112 - EAR file CDI type resolution performance regression

Hi folks

I've had a situation where if a component in the webapp part of an
EAR-based application performs a lookup programmatically to a CDI bean, and
that bean belongs to the EJB part of the EAR application, there's a
performance issue, versus older versions of TomEE. Essentially the OWB code
in older versions used to cache resolution by type when it was both
successful, and unsuccessful. More recently, only successful lookups are
cache.

The InjectionResolver is wrapped by a WebappInjectionResolver. This will
attempt to lookup by type in the webapp bean archives. If the bean cannot
be resolved here (because it is part of the EJB module),
WebappInjectionResolver will then look it up in the parent (which will
succeed).

InjectionResolver caches the lookups, but doesn't cache lookup failures
(previously it did). The impact is that each time the lookup happens,
WebappInjectionResolver will attempt to resolve (and fail) the bean in the
webapp archives first, without looking at the cache.

This can lead to a significant performance issue, depending on the number
of beans in the archives. I have measured it as 1000 TPS vs 60000 TPS.

The PR I have created introduces a parameter to enable the lookup
resolution failure cache: openejb.cache.cdi-type-resolution-failure. This
is off by default, and one should only turn it on if they are affected by
this, and are looking for the same behaviour as TomEE 1.7.x.

Jon