Repository navigation
perf(runtime): cache the interface class of chain link sources per class (3.4.x) - #702
Merged
Merged
Conversation
Backport of #655 to the 3.4.x line. ASTChain asks ASTProperty.getIndexedPropertyType() about every link of a property chain except the last one, and that calls OgnlExpressionCompiler.getInterfaceClass(source.getClass()). The default compiler copies the class's interface array and walks its hierarchy each time, although the answer only depends on the class. Add a ClassCache for it in OgnlCache, read through the new package-private OgnlRuntime.getInterfaceClass(Class), and use it from the two call sites in ASTProperty. OgnlCache.clear() drops it, it honours the ClassCacheInspector, and setCompiler() clears it since the cached values are answers of the previous compiler. The test drops the generic type parameters of ExpressionCompiler, which are not generic on this branch. The JMH benchmark from #655 is not ported, as this branch has no benchmarks module. Refs #650 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaszlenart
marked this pull request as ready for review
October 8, 2026 16:16
|
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.



Backport of #655 to the 3.4.x line. Refs #650
ASTChainasksASTProperty.getIndexedPropertyType()about every link of a property chain except the last, and that callsOgnlExpressionCompiler.getInterfaceClass(source.getClass()). The default compiler walks the class's interface hierarchy each time, although the answer only depends on the class.Change
ClassCacheinOgnlCache, created by the cache factory like the other per-class caches; its entry factory calls the current compiler'sgetInterfaceClass.OgnlRuntime.getInterfaceClass(Class)reads it; the two call sites inASTPropertyuse it.OgnlCache.clear()clears it, soclearCache()andclearAdditionalCache()both drop it.ClassCacheInspector.setCompiler(...)clears it, because the cached values are answers of the previous compiler.Differences from #655
OgnlRuntimeInterfaceClassCacheTestdrops the generic type parameters ofExpressionCompiler/OgnlExpressionCompiler, which aren't generic on this branch.OgnlPropertyChainPerformanceBenchmarksisn't ported: this branch has nobenchmarksmodule.Tests
getInterfaceClassdelegating straight to the compiler, 3 of the 6 new tests failed (a 5× evaluated chain asked the compiler 5 times instead of once). With the cache, all 6 pass and appear intarget/surefire-reports../mvnw clean test: 1190 tests, 0 failures.🤖 Generated with Claude Code