Repository navigation
Conversation
Filter an element's constraints by the groups of a strategy once and cache the result on the descriptor instead of streaming over all constraints for every validation. The per-strategy caches first match recently seen strategy instances by identity, as validation keeps passing the same ones.
- Cache the Default group redefinition per bean descriptor and requested group strategy instead of computing it for every bean and property. - Cache per bean and group strategy the properties that need a frame: those with constraints in scope, cascaded, or with constrained container elements. Properties with nothing to validate are no longer read. - Precompute whether a container descriptor is cascaded deeply.
Build a bean's property frames on first use per group, and skip properties without constraints in the current group, so that properties relevant only to groups that are never validated (such as later steps of a failing group sequence) are neither read nor resolved.
…oups directly - Combine the Default group redefinition and the relevant properties of a bean for a requested group strategy into one cached plan. - Validate a single-group strategy directly instead of through GroupStrategy#applyTo callbacks.
jungm
force-pushed
the
perf-4-validation-plan
branch
from
October 5, 2026 11:42
ce9e63e to
245457c
Compare
Member
|
Otherwise +1 |
tandraschko
reviewed
Oct 5, 2026
| if (cached != null) { | ||
| return cached; | ||
| } | ||
| final GroupStrategy local = getLocalGroupStrategy(groups); |
Member
There was a problem hiding this comment.
I usally use computeIfAbsent in this case, saves a call to the method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validates beans from plans cached per bean and group strategy, instead of working out what to validate on every call.
Relevant properties are those with constraints in scope, cascaded ones, and those with constrained container elements. Per-strategy caches first check up to eight already-seen strategy instances by identity (
GroupStrategyMap), since validation keeps passing the same ones.Evidence
Numbers are JMH throughput (
-p provider=bval -f 2 -wi 2 -i 3, 1 s iterations,-prof gc, JDK 25), measured against the PR below this one. The machine was busy, so throughput carries wide error bars; the bytes allocated per operation (B/op) are deterministic.All benchmarks
Merge Danger
Door: two-way
Blast Radius: groups