Avoid GroupChainGenerator to use reflection at runtime
Description
Environment
is duplicated by
Activity

Hardy FerentschikOctober 31, 2012 at 1:16 PM
Hear hear, and me thinking you where suggesting it to all projects
LOL
I only wrote that as I was assuming you would move to Jandex anyway; if you did you likely wouldn't need to concern about this anymore.
In the long term it would make sense. Especially if we could in this case take a already created index and skip most of the reflection calls all together. On the other hand, Validator is the RI of Bean Validation and we should be a little more careful with introducing new dependencies.
That said, I already fired up the profiler to have a closer look at this

Sanne GrinoveroOctober 31, 2012 at 1:07 PM
> I don't think this would make much of a difference and I don't want to introduce another dependency just for that.
Hear hear, and me thinking you where suggesting it to all projects
I only wrote that as I was assuming you would move to Jandex anyway; if you did you likely wouldn't need to concern about this anymore.

Hardy FerentschikOctober 31, 2012 at 1:00 PM
I see, you likely need a weak Key concurrent map, but that's going to introduce some overhead of its own.
Right, even though there is actually already some caching going on in this class. It uses a ConcurrentMap in this case. We probably should have a look at this as well. Either way, this does not cover the caching of the reflection call Class#getInterfaces. Thinking about it, much could be gained by adding a special case for the default group (java.validation.Default). In this case there is no need to call #getInterfaces at all and I would assume that is the most common case. Might be the reason why you noticed the contention in the first place. Probably a lot of parallel validations of the default group leading to contention around the lock for Class#getInterfaces.
What about using the Jandex index to read these?
I don't think this would make much of a difference and I don't want to introduce another dependency just for that.

Sanne GrinoveroOctober 30, 2012 at 6:48 PM
I see, you likely need a weak Key concurrent map, but that's going to introduce some overhead of its own. What about using the Jandex index to read these?

Hardy FerentschikOctober 30, 2012 at 6:01 PM
If you could improve on that you would getter better performance; maybe it's possible to store this information in some metadata which is discovered at boot time?
the list of groups to validate is passed dynamically for each validation call. It cannot be discovered at boot time. We could try to cache the reflection calls made for a given group/class, however, we would make sure that cache entries can be garbage collected as well.
Details
Assignee
Hardy FerentschikHardy FerentschikReporter
Sanne GrinoveroSanne GrinoveroParticipants
Hardy Ferentschik
Sanne GrinoveroComponents
Fix versions
Affects versions
Priority
Critical
Details
Details
Assignee

Reporter

Participants


It seems the GroupChainGenerator.insertInheritedGroups method is invoking Class.getInterfaces at runtime.
If you could improve on that you would getter better performance; maybe it's possible to store this information in some metadata which is discovered at boot time?