[
https://issues.apache.org/jira/browse/GROOVY-10307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18063210#comment-18063210
]
ASF GitHub Bot commented on GROOVY-10307:
-----------------------------------------
jamesfredley opened a new pull request, #2393:
URL: https://github.com/apache/groovy/pull/2393
## Summary
Backport JMH benchmarks for invokedynamic performance patterns and
Grails-like workload simulations from master to the GROOVY_4_0_X branch,
enabling performance comparison testing on Groovy 4.
## Changes
### New JMH benchmarks (16 files)
**Core Groovy performance** (`org.apache.groovy.perf`):
- `ClosureBench` - closure creation, reuse, capture, delegation, nesting,
currying, composition, trampoline, collection operations
- `GStringBench` - GString interpolation, concatenation, lazy evaluation
- `GroovyIdiomBench` - Groovy idioms (safe navigation, elvis, spread,
with/tap, destructuring)
- `LoopsBench` - for/while/each/times/upto loop patterns
- `MetaclassBench` - dynamic method dispatch overhead with metaclass changes
- `MethodInvocationBench` - method dispatch (instance, static, overloaded,
polymorphic, interface, dynamic)
- `OperatorBench` - operator overloading, comparisons, range operations
- `PropertyAccessBench` - property get/set patterns (direct, dynamic, nested)
- `RunnerRegistryBench` - GroovyRunnerRegistry iterator performance
**Grails-like patterns** (`org.apache.groovy.perf.grails`):
- `CallSiteInvalidationBench` - SwitchPoint invalidation overhead for
cross-type and same-type metaclass changes
- `CategoryBench` - category usage patterns (single, nested, simultaneous,
shadowing)
- `DynamicDispatchBench` - methodMissing, propertyMissing, invokeMethod,
ExpandoMetaClass injection
- `GrailsLikePatternsBench` - composite patterns (service chains, controller
actions, domain validation, config DSL, markup builder, full request cycle)
- `GrailsWorkloadBench` - collection closure chains, spread operator, nested
closure delegation, GString interpolation, project metrics aggregation
- `MetaclassChangeBench` - metaclass modification impact (expando additions,
replacements, multi-class cascade, burst/steady-state, closure dispatch)
- `MetaclassVariationBench` - per-instance ExpandoMetaClass overhead (GORM
domain class enhancement pattern)
### Build changes
- Updated `org.apache.groovy-performance.gradle` to support `indy` property
for toggling invokedynamic mode in JMH compilation (`-Pindy=true|false`,
defaults to true)
- Added `jmh` task input tracking and `jmhJar` output configuration
### CI workflows
- `groovy-jmh.yml` - runs JMH benchmarks with invokedynamic enabled (matrix:
bench, core, grails suites)
- `groovy-jmh-classic.yml` - runs JMH benchmarks with classic (non-indy)
bytecode
### Groovy 4 compatibility adaptation
- `DynamicDispatchBench`: moved `DynamicFinder`, `DynamicProperties`, and
`MethodInterceptor` from static inner classes to package-level classes because
Groovy 4 does not support `methodMissing`/`propertyMissing` on static inner
classes
## Verification
- Compiled successfully with `./gradlew :performance:jmhClasses` (indy mode)
- Compiled successfully with `./gradlew :performance:jmhClasses
-Pindy=false` (classic mode)
> Groovy 4 runtime performance on average 2.4x slower than Groovy 3
> -----------------------------------------------------------------
>
> Key: GROOVY-10307
> URL: https://issues.apache.org/jira/browse/GROOVY-10307
> Project: Groovy
> Issue Type: Bug
> Components: bytecode, performance
> Affects Versions: 4.0.0-beta-1, 3.0.9
> Environment: OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9
> (build 11.0.11+9)
> OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
> WIN10 (tests) / REL 8 (web application)
> IntelliJ 2021.2
> Reporter: mgroovy
> Priority: Major
> Attachments: groovy_3_0_9_gc.png, groovy_3_0_9_loop2.png,
> groovy_3_0_9_loop4.png, groovy_3_0_9_mem.png, groovy_4_0_0_b1_loop2.png,
> groovy_4_0_0_b1_loop4.png, groovy_4_0_0_b1_loop4_gc.png,
> groovy_4_0_0_b1_loop4_mem.png,
> groovysql_performance_groovy4_2_xx_yy_zzzz.groovy, loops.groovy,
> profile3.txt, profile4-loops.txt, profile4.txt, profile4d.txt
>
>
> Groovy 4.0.0-beta-1 runtime performance in our framework is on average 2 to 3
> times slower compared to using Groovy 3.0.9 (regular i.e. non-INDY)
> * Our complete framework and application code is completely written in
> Groovy, spread over multiple IntelliJ modules
> ** mixed @CompileDynamic/@TypeChecked and @CompileStatic
> ** No Java classes left in project, i.e. no cross compilation occurs
> * We build using IntelliJ 2021.2 Groovy build process, then run / deploy the
> compiled class files
> ** We do _not_ use a Groovy based DSL, nor do we execute Groovy scripts
> during execution
> * Performance degradation when using Groovy 4.0.0-beta-1 instead of Groovy
> 3.0.9 (non-INDY):
> ** The performance of the largest of our web applications has dropped 3x
> (startup) / 2x (table refresh) respectively
> *** Stack: Tomcat/Vaadin/Ebean plus framework generated SQL
> ** Our test suite runs about 2.4 times as long as before (120 min when using
> G4, compared to about 50 min with G3)
> *** JUnit 5
> *** test suite also contains no scripts / dynamic code execution
> *** Individual test performance varies: A small number of tests runs faster,
> but the majority is slower, with some extreme cases taking nearly 10x as long
> to finish
> * Using Groovy 3.0.9 INDY displays nearly identical performance degradation,
> so it seems that the use of invoke dynamic is somehow at fault
--
This message was sent by Atlassian Jira
(v8.20.10#820010)