Skip to content

GROOVY-12065: Implement peephole optimization for bytecode generation#2591

Open
daniellansun wants to merge 1 commit into
masterfrom
GROOVY-12065
Open

GROOVY-12065: Implement peephole optimization for bytecode generation#2591
daniellansun wants to merge 1 commit into
masterfrom
GROOVY-12065

Conversation

@daniellansun

Copy link
Copy Markdown
Contributor

This comment was marked as outdated.

@asf-gitbox-commits asf-gitbox-commits force-pushed the GROOVY-12065 branch 2 times, most recently from 377c68b to d1aeb66 Compare June 6, 2026 13:39
@daniellansun daniellansun changed the title Implement peephole optimization for constant loading in bytecode generation GROOVY-12065: Implement peephole optimization for constant loading in bytecode generation Jun 6, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: d61c051 Previous: 80d37ed Ratio
org.apache.groovy.bench.GeneratedHashCodeBench.generated_hashcode_on_instance_with_null_properties 206473.262991253 ops/ms 101686.67767570786 ops/ms 2.03
org.apache.groovy.bench.NonCapturingLambdaBench.capturingLambdaApply 114855.81227187793 ops/ms 44607.24325271937 ops/ms 2.57
org.apache.groovy.bench.NonCapturingLambdaBench.nonCapturingLambdaApply 4462045.07373645 ops/ms 2666189.9899859093 ops/ms 1.67
org.apache.groovy.bench.NonCapturingLambdaBench.streamMapNonCapturing 26851.632887995627 ops/ms 12128.564491971898 ops/ms 2.21
org.apache.groovy.bench.NonCapturingLambdaBench.streamReduceNonCapturing 31584.498780732538 ops/ms 16476.687913502024 ops/ms 1.92
org.apache.groovy.bench.StaticMethodCallIndyBench.instanceChain_groovy 186.47874964689734 ops/ms 88.07590042330493 ops/ms 2.12
org.apache.groovy.bench.StaticMethodCallIndyBench.instanceFib_groovy 2.0535216132698673 ops/ms 0.9529014936194289 ops/ms 2.16
org.apache.groovy.bench.StaticMethodCallIndyBench.instanceSum_groovy 248.8433206485209 ops/ms 112.34655416823993 ops/ms 2.21
org.apache.groovy.bench.StaticMethodCallIndyBench.staticChain_groovy 1101.2554170097449 ops/ms 558.6234326127244 ops/ms 1.97
org.apache.groovy.bench.StaticMethodCallIndyBench.staticChain_groovyCS 4015.2515353298645 ops/ms 2244.546309477836 ops/ms 1.79
org.apache.groovy.bench.StaticMethodCallIndyBench.staticChain_java 4000.5574692987348 ops/ms 2249.8921119057513 ops/ms 1.78
org.apache.groovy.bench.StaticMethodCallIndyBench.staticFib_groovy 4.7410570800946275 ops/ms 2.0170595087888286 ops/ms 2.35
org.apache.groovy.bench.StaticMethodCallIndyBench.staticFib_groovyCS 6.416847256690123 ops/ms 3.378655965391002 ops/ms 1.90
org.apache.groovy.bench.StaticMethodCallIndyBench.staticFib_java 6.433115477992071 ops/ms 3.3886799437423605 ops/ms 1.90
org.apache.groovy.bench.StaticMethodCallIndyBench.staticSum_groovy 1414.7352251610673 ops/ms 561.1447803969829 ops/ms 2.52
org.apache.groovy.bench.StaticMethodCallIndyBench.staticSum_groovyCS 4726.8031520249715 ops/ms 3001.903992147817 ops/ms 1.57
org.apache.groovy.bench.StaticMethodCallIndyBench.staticSum_java 4746.986812329111 ops/ms 2996.0612402877814 ops/ms 1.58
org.apache.groovy.bench.dispatch.CallsiteBench.dispatch_1_monomorphic_groovy 7341.397993341676 ops/ms 3542.3625342376827 ops/ms 2.07
org.apache.groovy.bench.dispatch.CallsiteBench.dispatch_1_monomorphic_groovyCS 27498.867932101064 ops/ms 15666.595252222818 ops/ms 1.76
org.apache.groovy.bench.dispatch.CallsiteBench.dispatch_1_monomorphic_java 73262.78201459142 ops/ms 35558.21847709362 ops/ms 2.06
org.apache.groovy.bench.dispatch.CallsiteBench.dispatch_3_polymorphic_groovyCS 25836.540603735324 ops/ms 13563.842036943028 ops/ms 1.90
org.apache.groovy.bench.dispatch.CallsiteBench.dispatch_3_polymorphic_java 8581.052253645397 ops/ms 1936.1250218518248 ops/ms 4.43
org.apache.groovy.bench.dispatch.CallsiteBench.dispatch_8_megamorphic_groovyCS 25962.532224721283 ops/ms 13586.404324443225 ops/ms 1.91
org.apache.groovy.bench.dispatch.CallsiteBench.dispatch_8_megamorphic_java 8595.278968583092 ops/ms 1599.7052607830838 ops/ms 5.37

This comment was automatically generated by workflow using github-action-benchmark.

@codecov-commenter

codecov-commenter commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.13265% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.6424%. Comparing base (80d37ed) to head (d61c051).

Files with missing lines Patch % Lines
.../classgen/asm/PeepholeOptimizingMethodVisitor.java 94.5800% 8 Missing and 12 partials ⚠️
...rg/codehaus/groovy/classgen/AsmClassGenerator.java 81.8182% 2 Missing ⚠️
...org/codehaus/groovy/classgen/asm/OperandStack.java 83.3333% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2591        +/-   ##
==================================================
+ Coverage     68.5703%   68.6424%   +0.0721%     
- Complexity      33809      33953       +144     
==================================================
  Files            1524       1525         +1     
  Lines          128143     128495       +352     
  Branches        23292      23318        +26     
==================================================
+ Hits            87868      88202       +334     
- Misses          32476      32480         +4     
- Partials         7799       7813        +14     
Files with missing lines Coverage Δ
...g/codehaus/groovy/classgen/asm/BytecodeHelper.java 88.8283% <100.0000%> (-0.4867%) ⬇️
...g/codehaus/groovy/classgen/asm/CallSiteWriter.java 84.6154% <100.0000%> (+0.1494%) ⬆️
...org/codehaus/groovy/classgen/asm/OperandStack.java 77.6398% <83.3333%> (-0.9730%) ⬇️
...rg/codehaus/groovy/classgen/AsmClassGenerator.java 85.0399% <81.8182%> (+0.0327%) ⬆️
.../classgen/asm/PeepholeOptimizingMethodVisitor.java 94.5800% <94.5800%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

JMH summary — classic (commit 046283f)

Speedup vs trailing 90-day baseline on gh-pages. Higher = faster.
1.00 = in line with history. Per-benchmark ratio, geomean within group.
Time-per-op units inverted so direction is consistent.

Group Speedup n
bench 1.003 × 26
core 1.038 × 77
grails 0.991 × 80

Baseline: dev/bench/jmh/<part>/classic/data.js on gh-pages, trailing 90 days. Daily dashboard · Per-suite raw data

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

JMH summary — indy (commit 046283f)

Speedup vs trailing 90-day baseline on gh-pages. Higher = faster.
1.00 = in line with history. Per-benchmark ratio, geomean within group.
Time-per-op units inverted so direction is consistent.

Group Speedup n
bench 1.966 × 26
core 3.447 × 77
grails 2.523 × 80

Baseline: dev/bench/jmh/<part>/indy/data.js on gh-pages, trailing 90 days. Daily dashboard · Per-suite raw data

@daniellansun daniellansun changed the title GROOVY-12065: Implement peephole optimization for constant loading in bytecode generation GROOVY-12065: Implement peephole optimization for bytecode generation Jun 6, 2026
@daniellansun daniellansun marked this pull request as draft June 6, 2026 16:51
@daniellansun daniellansun self-assigned this Jun 6, 2026
@asf-gitbox-commits asf-gitbox-commits force-pushed the GROOVY-12065 branch 2 times, most recently from 4525305 to 2a55a90 Compare June 6, 2026 18:52
Comment on lines +575 to +576
} else if (isPrimitiveLong(type) || isPrimitiveFloat(type) || isPrimitiveDouble(type)) {
mv.visitLdcInsn(value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this require LCONST_0 and so on so the operand stack type is correct?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it was different when most of the bytecode code was written, but current version of asm actually handle the special case internally: https://asm.ow2.io/javadoc/org/objectweb/asm/MethodVisitor.html#visitLdcInsn(java.lang.Object) - AFAIK

@daniellansun daniellansun marked this pull request as ready for review July 3, 2026 23:00
@daniellansun daniellansun requested a review from paulk-asert July 3, 2026 23:44
@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@testlens-app

testlens-app Bot commented Jul 4, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: d61c051
▶️ Tests: 88421 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants