GROOVY-10307: add JMH benchmarks for invokedynamic performance patterns#2381
Merged
paulk-asert merged 2 commits intoapache:masterfrom Feb 16, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new org.apache.groovy.perf JMH benchmark suite under the performance subproject to measure invokedynamic-heavy Groovy language patterns (closures, operators, property access, GStrings, etc.), complementing the existing org.apache.groovy.bench benchmarks.
Changes:
- Add 7 new Groovy JMH benchmark classes under
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf. - Cover Groovy-specific invokedynamic patterns: closure usage, loop/dispatch patterns, method invocation shapes, GString usage, property access styles, operator overloading, and common Groovy idioms.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/ClosureBench.groovy | Adds closure-focused microbenchmarks (creation, reuse, delegation, curry, trampoline, collection ops). |
| subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/GStringBench.groovy | Adds GString interpolation/toString/map-key usage benchmarks. |
| subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/GroovyIdiomBench.groovy | Adds benchmarks for Groovy idioms (safe-nav, spread-dot, elvis, with/tap, ranges, as coercion). |
| subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/LoopsBench.groovy | Adds loop-centric benchmarks comparing closure-in-loop vs method calls and nested iteration patterns. |
| subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/MethodInvocationBench.groovy | Adds benchmarks for method call shapes (instance/static, overload resolution, mono/poly call sites, interface dispatch, dynamic receiver). |
| subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/OperatorBench.groovy | Adds operator-overloading benchmarks (arithmetic, BigDecimal, list/map subscripts, leftShift, equals, spaceship, comparisons, unary minus, in). |
| subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy | Adds benchmarks for property/field/getter-setter access, dynamic receiver property access, map bracket/dot property, and chaining. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/ClosureBench.groovy
Outdated
Show resolved
Hide resolved
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/OperatorBench.groovy
Show resolved
Hide resolved
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/LoopsBench.groovy
Show resolved
Hide resolved
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/LoopsBench.groovy
Show resolved
Hide resolved
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy
Show resolved
Hide resolved
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy
Show resolved
Hide resolved
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy
Outdated
Show resolved
Hide resolved
subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/GroovyIdiomBench.groovy
Show resolved
Hide resolved
8ec3637 to
b86daf9
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2381 +/- ##
==================================================
+ Coverage 66.7154% 66.7163% +0.0009%
- Complexity 29846 29847 +1
==================================================
Files 1382 1382
Lines 116180 116180
Branches 20491 20491
==================================================
+ Hits 77510 77511 +1
Misses 32323 32323
+ Partials 6347 6346 -1 🚀 New features to boost your workflow:
|
Contributor
|
LGTM |
jamesfredley
added a commit
to jamesfredley/groovy
that referenced
this pull request
Feb 26, 2026
…oints Add 43 JMH benchmarks across 4 files targeting the metaclass invalidation patterns that cause performance regression in Grails applications under invokedynamic. These complement the general-purpose benchmarks from apache#2381 by exercising the specific dynamic dispatch patterns identified in apache#2374 and apache#2377. New benchmark files: MetaclassChangeBench (11 benchmarks) - ExpandoMetaClass method addition during method dispatch - Metaclass replacement cycles - Multi-class invalidation cascade (change on ServiceA invalidates ServiceB/C) - Burst-then-steady-state (simulates Grails startup then request handling) - Property access and closure dispatch under metaclass churn CategoryBench (10 benchmarks) - use(Category) blocks inside vs outside loops - Nested and simultaneous multi-category scopes - Collateral invalidation damage on non-category call sites - Category method shadowing existing methods DynamicDispatchBench (12 benchmarks) - methodMissing with single/rotating names (dynamic finders) - propertyMissing read/write (Grails params/session) - GroovyInterceptable invokeMethod interception (transactional services) - ExpandoMetaClass-injected method calls mixed with real methods - def-typed monomorphic and polymorphic dispatch GrailsLikePatternsBench (10 benchmarks) - Service chain: validation, CRUD, collection processing - Controller action: param binding, service call, model/view rendering - Domain validation with dynamic property access (this."$field") - Configuration DSL with nested @DelegatesTo closures - Markup builder with nested tag/closure rendering - Full request cycle simulation with and without metaclass churn Run with: ./gradlew perf:jmh -PbenchInclude=perf
jamesfredley
added a commit
to jamesfredley/groovy
that referenced
this pull request
Feb 26, 2026
…oints Add 43 JMH benchmarks across 4 files targeting the metaclass invalidation patterns that cause performance regression in Grails applications under invokedynamic. These complement the general-purpose benchmarks from apache#2381 by exercising the specific dynamic dispatch patterns identified in apache#2374 and apache#2377. New benchmark files: MetaclassChangeBench (11 benchmarks) - ExpandoMetaClass method addition during method dispatch - Metaclass replacement cycles - Multi-class invalidation cascade (change on ServiceA invalidates ServiceB/C) - Burst-then-steady-state (simulates Grails startup then request handling) - Property access and closure dispatch under metaclass churn CategoryBench (10 benchmarks) - use(Category) blocks inside vs outside loops - Nested and simultaneous multi-category scopes - Collateral invalidation damage on non-category call sites - Category method shadowing existing methods DynamicDispatchBench (12 benchmarks) - methodMissing with single/rotating names (dynamic finders) - propertyMissing read/write (Grails params/session) - GroovyInterceptable invokeMethod interception (transactional services) - ExpandoMetaClass-injected method calls mixed with real methods - def-typed monomorphic and polymorphic dispatch GrailsLikePatternsBench (10 benchmarks) - Service chain: validation, CRUD, collection processing - Controller action: param binding, service call, model/view rendering - Domain validation with dynamic property access (this."$field") - Configuration DSL with nested @DelegatesTo closures - Markup builder with nested tag/closure rendering - Full request cycle simulation with and without metaclass churn Run with: ./gradlew perf:jmh -PbenchInclude=perf
paulk-asert
pushed a commit
that referenced
this pull request
Feb 27, 2026
…oints Add 43 JMH benchmarks across 4 files targeting the metaclass invalidation patterns that cause performance regression in Grails applications under invokedynamic. These complement the general-purpose benchmarks from #2381 by exercising the specific dynamic dispatch patterns identified in #2374 and #2377. New benchmark files: MetaclassChangeBench (11 benchmarks) - ExpandoMetaClass method addition during method dispatch - Metaclass replacement cycles - Multi-class invalidation cascade (change on ServiceA invalidates ServiceB/C) - Burst-then-steady-state (simulates Grails startup then request handling) - Property access and closure dispatch under metaclass churn CategoryBench (10 benchmarks) - use(Category) blocks inside vs outside loops - Nested and simultaneous multi-category scopes - Collateral invalidation damage on non-category call sites - Category method shadowing existing methods DynamicDispatchBench (12 benchmarks) - methodMissing with single/rotating names (dynamic finders) - propertyMissing read/write (Grails params/session) - GroovyInterceptable invokeMethod interception (transactional services) - ExpandoMetaClass-injected method calls mixed with real methods - def-typed monomorphic and polymorphic dispatch GrailsLikePatternsBench (10 benchmarks) - Service chain: validation, CRUD, collection processing - Controller action: param binding, service call, model/view rendering - Domain validation with dynamic property access (this."$field") - Configuration DSL with nested @DelegatesTo closures - Markup builder with nested tag/closure rendering - Full request cycle simulation with and without metaclass churn Run with: ./gradlew perf:jmh -PbenchInclude=perf
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.
https://issues.apache.org/jira/browse/GROOVY-10307
Adds 7 JMH benchmark files to the
performancesubproject covering common Groovy patterns exercised through invokedynamic. These benchmarks complement the existingorg.apache.groovy.benchsuite (Ackermann, Ary, Fibo, GeneratedHashCode, Callsite) by focusing on Groovy-specific language features.Run with:
./gradlew perf:jmh -PbenchInclude=perfBenchmark Files
ClosureBenchLoopsBenchMethodInvocationBenchGStringBenchPropertyAccessBenchOperatorBenchGroovyIdiomBench74 benchmarks total, all using proper
Blackholeconsumption to prevent dead-code elimination.