This is an automated email from the ASF dual-hosted git repository. paulk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
commit a6a83ab22f0cd3fd18d67c530e55ff2eab0cb22f Author: James Fredley <[email protected]> AuthorDate: Tue Mar 3 08:12:31 2026 -0500 fix: address Copilot review feedback on benchmark code Remove unused ExpandoMetaClass import from CallSiteInvalidationBench. Clarify Javadoc on dynamicFinderCalls and mixedCompiledAndDynamicFinders to state that injection cost is intentionally included since these model per-request GORM behavior. Replace System.nanoTime() with a deterministic counter for metaclass property name variation in fullAnalysisWithInvalidation to eliminate unrelated overhead and improve run-to-run comparability. --- .../org/apache/groovy/perf/grails/CallSiteInvalidationBench.groovy | 1 - .../groovy/org/apache/groovy/perf/grails/GrailsWorkloadBench.groovy | 5 +++-- .../org/apache/groovy/perf/grails/MetaclassVariationBench.groovy | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/CallSiteInvalidationBench.groovy b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/CallSiteInvalidationBench.groovy index 02bedfd503..b239c44333 100644 --- a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/CallSiteInvalidationBench.groovy +++ b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/CallSiteInvalidationBench.groovy @@ -18,7 +18,6 @@ */ package org.apache.groovy.perf.grails -import groovy.lang.ExpandoMetaClass import groovy.lang.GroovySystem import org.openjdk.jmh.annotations.* diff --git a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/GrailsWorkloadBench.groovy b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/GrailsWorkloadBench.groovy index 372fdeca6a..2efac25abc 100644 --- a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/GrailsWorkloadBench.groovy +++ b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/GrailsWorkloadBench.groovy @@ -103,6 +103,7 @@ class GrailsWorkloadBench { List<Employee> employees List<Project> projects List<Task> tasks + int invalidationCounter @Setup(Level.Iteration) void setup() { @@ -430,7 +431,7 @@ class GrailsWorkloadBench { @Benchmark void fullAnalysisWithInvalidation(Blackhole bh) { // Ongoing framework metaclass activity - PluginConfig.metaClass."preRequest${System.nanoTime() % 3}" = { -> 'init' } + PluginConfig.metaClass."preRequest${invalidationCounter++ % 3}" = { -> 'init' } // Employee analysis def activeEmps = employees.findAll { it.isActive } @@ -444,7 +445,7 @@ class GrailsWorkloadBench { } // Mid-request metaclass change - PluginConfig.metaClass."midRequest${System.nanoTime() % 3}" = { -> 'lazy' } + PluginConfig.metaClass."midRequest${invalidationCounter++ % 3}" = { -> 'lazy' } // Project metrics def projectSummary = projects.collect { proj -> diff --git a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/MetaclassVariationBench.groovy b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/MetaclassVariationBench.groovy index 1fbc2719da..2924c8f9a0 100644 --- a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/MetaclassVariationBench.groovy +++ b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/MetaclassVariationBench.groovy @@ -203,7 +203,7 @@ class MetaclassVariationBench { bh.consume(sum) } - /** Calling dynamic finders injected via static metaclass. */ + /** Injection + invocation of dynamic finders via static metaclass (models per-request GORM cost). */ @Benchmark void dynamicFinderCalls(Blackhole bh) { // Inject dynamic finders @@ -222,7 +222,7 @@ class MetaclassVariationBench { } } - /** Mixed compiled method calls and dynamic finder calls. */ + /** Mixed compiled method calls and dynamic finder injection + invocation (models per-request GORM cost). */ @Benchmark void mixedCompiledAndDynamicFinders(Blackhole bh) { DomainEntity.metaClass.static.findByName = { String n ->
