-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix local var hoisting #7624
Fix local var hoisting #7624
Conversation
Debugger benchmarksParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 8 metrics, 7 unstable metrics. See unchanged results
Request duration reports for reportsgantt
title reports - request duration [CI 0.99] : candidate=None, baseline=None
dateFormat X
axisFormat %s
section baseline
noprobe (308.078 µs) : 266, 350
. : milestone, 308,
basic (296.15 µs) : 286, 307
. : milestone, 296,
loop (10.348 ms) : 10309, 10386
. : milestone, 10348,
section candidate
noprobe (298.116 µs) : 266, 330
. : milestone, 298,
basic (301.355 µs) : 291, 311
. : milestone, 301,
loop (10.253 ms) : 10220, 10285
. : milestone, 10253,
|
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 15 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.064 s) : 0, 1063637
Total [baseline] (10.341 s) : 0, 10340928
Agent [candidate] (1.07 s) : 0, 1070287
Total [candidate] (10.331 s) : 0, 10331412
section appsec
Agent [baseline] (1.199 s) : 0, 1199234
Total [baseline] (10.641 s) : 0, 10641002
Agent [candidate] (1.198 s) : 0, 1198301
Total [candidate] (10.632 s) : 0, 10631738
section iast
Agent [baseline] (1.193 s) : 0, 1193064
Total [baseline] (10.87 s) : 0, 10870310
Agent [candidate] (1.191 s) : 0, 1191055
Total [candidate] (10.774 s) : 0, 10773980
section profiling
Agent [baseline] (1.262 s) : 0, 1262408
Total [baseline] (10.571 s) : 0, 10570777
Agent [candidate] (1.26 s) : 0, 1259719
Total [candidate] (10.602 s) : 0, 10601699
gantt
title petclinic - break down per module: candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (678.657 ms) : 0, 678657
BytebuddyAgent [candidate] (683.219 ms) : 0, 683219
GlobalTracer [baseline] (310.728 ms) : 0, 310728
GlobalTracer [candidate] (313.138 ms) : 0, 313138
AppSec [baseline] (52.455 ms) : 0, 52455
AppSec [candidate] (52.018 ms) : 0, 52018
Remote Config [baseline] (673.668 µs) : 0, 674
Remote Config [candidate] (664.0 µs) : 0, 664
Telemetry [baseline] (7.518 ms) : 0, 7518
Telemetry [candidate] (7.527 ms) : 0, 7527
section appsec
BytebuddyAgent [baseline] (701.686 ms) : 0, 701686
BytebuddyAgent [candidate] (701.008 ms) : 0, 701008
GlobalTracer [baseline] (303.532 ms) : 0, 303532
GlobalTracer [candidate] (303.668 ms) : 0, 303668
AppSec [baseline] (160.823 ms) : 0, 160823
AppSec [candidate] (160.043 ms) : 0, 160043
Remote Config [baseline] (628.848 µs) : 0, 629
Remote Config [candidate] (640.508 µs) : 0, 641
Telemetry [baseline] (9.13 ms) : 0, 9130
Telemetry [candidate] (9.397 ms) : 0, 9397
IAST [baseline] (19.674 ms) : 0, 19674
IAST [candidate] (19.884 ms) : 0, 19884
section iast
BytebuddyAgent [baseline] (795.461 ms) : 0, 795461
BytebuddyAgent [candidate] (792.624 ms) : 0, 792624
GlobalTracer [baseline] (299.042 ms) : 0, 299042
GlobalTracer [candidate] (299.544 ms) : 0, 299544
AppSec [baseline] (52.625 ms) : 0, 52625
AppSec [candidate] (51.971 ms) : 0, 51971
Remote Config [baseline] (627.072 µs) : 0, 627
Remote Config [candidate] (635.75 µs) : 0, 636
Telemetry [baseline] (8.05 ms) : 0, 8050
Telemetry [candidate] (7.332 ms) : 0, 7332
IAST [baseline] (23.577 ms) : 0, 23577
IAST [candidate] (25.242 ms) : 0, 25242
section profiling
ProfilingAgent [baseline] (96.05 ms) : 0, 96050
ProfilingAgent [candidate] (95.887 ms) : 0, 95887
BytebuddyAgent [baseline] (673.573 ms) : 0, 673573
BytebuddyAgent [candidate] (672.199 ms) : 0, 672199
GlobalTracer [baseline] (393.537 ms) : 0, 393537
GlobalTracer [candidate] (392.975 ms) : 0, 392975
AppSec [baseline] (53.121 ms) : 0, 53121
AppSec [candidate] (52.623 ms) : 0, 52623
Remote Config [baseline] (658.367 µs) : 0, 658
Remote Config [candidate] (657.222 µs) : 0, 657
Telemetry [baseline] (7.428 ms) : 0, 7428
Telemetry [candidate] (7.404 ms) : 0, 7404
Profiling [baseline] (96.075 ms) : 0, 96075
Profiling [candidate] (95.911 ms) : 0, 95911
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.065 s) : 0, 1064899
Total [baseline] (8.531 s) : 0, 8530746
Agent [candidate] (1.071 s) : 0, 1070986
Total [candidate] (8.547 s) : 0, 8546811
section iast
Agent [baseline] (1.184 s) : 0, 1183818
Total [baseline] (9.014 s) : 0, 9013642
Agent [candidate] (1.189 s) : 0, 1188720
Total [candidate] (9.065 s) : 0, 9065251
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.207 s) : 0, 1206930
Total [baseline] (8.981 s) : 0, 8980880
Agent [candidate] (1.207 s) : 0, 1206854
Total [candidate] (9.028 s) : 0, 9028182
section iast_TELEMETRY_OFF
Agent [baseline] (1.193 s) : 0, 1193400
Total [baseline] (9.012 s) : 0, 9012011
Agent [candidate] (1.202 s) : 0, 1202484
Total [candidate] (9.062 s) : 0, 9062150
gantt
title insecure-bank - break down per module: candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (680.184 ms) : 0, 680184
BytebuddyAgent [candidate] (683.494 ms) : 0, 683494
GlobalTracer [baseline] (310.322 ms) : 0, 310322
GlobalTracer [candidate] (313.32 ms) : 0, 313320
AppSec [baseline] (52.559 ms) : 0, 52559
AppSec [candidate] (52.312 ms) : 0, 52312
Remote Config [baseline] (665.956 µs) : 0, 666
Remote Config [candidate] (669.998 µs) : 0, 670
Telemetry [baseline] (7.53 ms) : 0, 7530
Telemetry [candidate] (7.499 ms) : 0, 7499
section iast
BytebuddyAgent [baseline] (787.627 ms) : 0, 787627
BytebuddyAgent [candidate] (791.212 ms) : 0, 791212
GlobalTracer [baseline] (298.021 ms) : 0, 298021
GlobalTracer [candidate] (298.771 ms) : 0, 298771
AppSec [baseline] (53.252 ms) : 0, 53252
AppSec [candidate] (53.303 ms) : 0, 53303
IAST [baseline] (23.428 ms) : 0, 23428
IAST [candidate] (23.723 ms) : 0, 23723
Remote Config [baseline] (634.239 µs) : 0, 634
Remote Config [candidate] (649.615 µs) : 0, 650
Telemetry [baseline] (7.286 ms) : 0, 7286
Telemetry [candidate] (7.408 ms) : 0, 7408
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (803.972 ms) : 0, 803972
BytebuddyAgent [candidate] (804.295 ms) : 0, 804295
GlobalTracer [baseline] (302.972 ms) : 0, 302972
GlobalTracer [candidate] (303.147 ms) : 0, 303147
AppSec [baseline] (52.993 ms) : 0, 52993
AppSec [candidate] (53.8 ms) : 0, 53800
IAST [baseline] (25.202 ms) : 0, 25202
IAST [candidate] (23.778 ms) : 0, 23778
Remote Config [baseline] (609.012 µs) : 0, 609
Remote Config [candidate] (604.588 µs) : 0, 605
Telemetry [baseline] (7.325 ms) : 0, 7325
Telemetry [candidate] (7.339 ms) : 0, 7339
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (793.187 ms) : 0, 793187
BytebuddyAgent [candidate] (799.521 ms) : 0, 799521
GlobalTracer [baseline] (301.058 ms) : 0, 301058
GlobalTracer [candidate] (303.15 ms) : 0, 303150
AppSec [baseline] (55.8 ms) : 0, 55800
AppSec [candidate] (55.211 ms) : 0, 55211
IAST [baseline] (21.628 ms) : 0, 21628
IAST [candidate] (21.047 ms) : 0, 21047
Remote Config [baseline] (607.462 µs) : 0, 607
Remote Config [candidate] (610.009 µs) : 0, 610
Telemetry [baseline] (7.387 ms) : 0, 7387
Telemetry [candidate] (9.096 ms) : 0, 9096
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 18 unstable metrics. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section baseline
no_agent (368.999 µs) : 349, 389
. : milestone, 369,
iast (479.511 µs) : 458, 501
. : milestone, 480,
iast_FULL (548.947 µs) : 528, 570
. : milestone, 549,
iast_GLOBAL (500.268 µs) : 479, 522
. : milestone, 500,
iast_HARDCODED_SECRET_DISABLED (482.782 µs) : 460, 505
. : milestone, 483,
iast_INACTIVE (445.784 µs) : 424, 468
. : milestone, 446,
iast_TELEMETRY_OFF (470.789 µs) : 448, 494
. : milestone, 471,
tracing (449.692 µs) : 426, 473
. : milestone, 450,
section candidate
no_agent (364.055 µs) : 344, 384
. : milestone, 364,
iast (478.958 µs) : 458, 500
. : milestone, 479,
iast_FULL (548.264 µs) : 527, 570
. : milestone, 548,
iast_GLOBAL (497.128 µs) : 476, 518
. : milestone, 497,
iast_HARDCODED_SECRET_DISABLED (479.225 µs) : 458, 500
. : milestone, 479,
iast_INACTIVE (442.76 µs) : 422, 464
. : milestone, 443,
iast_TELEMETRY_OFF (476.066 µs) : 454, 499
. : milestone, 476,
tracing (435.426 µs) : 416, 455
. : milestone, 435,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section baseline
no_agent (1.345 ms) : 1326, 1365
. : milestone, 1345,
appsec (1.732 ms) : 1708, 1756
. : milestone, 1732,
appsec_no_iast (1.734 ms) : 1710, 1758
. : milestone, 1734,
iast (1.462 ms) : 1440, 1484
. : milestone, 1462,
profiling (1.476 ms) : 1452, 1500
. : milestone, 1476,
tracing (1.463 ms) : 1439, 1488
. : milestone, 1463,
section candidate
no_agent (1.326 ms) : 1306, 1346
. : milestone, 1326,
appsec (1.714 ms) : 1691, 1738
. : milestone, 1714,
appsec_no_iast (1.717 ms) : 1693, 1741
. : milestone, 1717,
iast (1.482 ms) : 1459, 1505
. : milestone, 1482,
profiling (1.467 ms) : 1442, 1491
. : milestone, 1467,
tracing (1.462 ms) : 1438, 1487
. : milestone, 1462,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section baseline
no_agent (1.469 ms) : 1458, 1481
. : milestone, 1469,
appsec (2.311 ms) : 2270, 2352
. : milestone, 2311,
iast (2.074 ms) : 2023, 2125
. : milestone, 2074,
iast_GLOBAL (2.122 ms) : 2071, 2173
. : milestone, 2122,
profiling (1.932 ms) : 1892, 1971
. : milestone, 1932,
tracing (1.911 ms) : 1872, 1949
. : milestone, 1911,
section candidate
no_agent (1.474 ms) : 1463, 1486
. : milestone, 1474,
appsec (2.307 ms) : 2266, 2348
. : milestone, 2307,
iast (2.071 ms) : 2019, 2122
. : milestone, 2071,
iast_GLOBAL (2.123 ms) : 2071, 2174
. : milestone, 2123,
profiling (1.93 ms) : 1890, 1970
. : milestone, 1930,
tracing (1.916 ms) : 1877, 1954
. : milestone, 1916,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~5fc276336e, baseline=1.40.0-SNAPSHOT~1429d59b51
dateFormat X
axisFormat %s
section baseline
no_agent (15.038 s) : 15038000, 15038000
. : milestone, 15038000,
appsec (15.191 s) : 15191000, 15191000
. : milestone, 15191000,
iast (18.94 s) : 18940000, 18940000
. : milestone, 18940000,
iast_GLOBAL (17.965 s) : 17965000, 17965000
. : milestone, 17965000,
profiling (15.334 s) : 15334000, 15334000
. : milestone, 15334000,
tracing (15.262 s) : 15262000, 15262000
. : milestone, 15262000,
section candidate
no_agent (15.044 s) : 15044000, 15044000
. : milestone, 15044000,
appsec (15.286 s) : 15286000, 15286000
. : milestone, 15286000,
iast (19.202 s) : 19202000, 19202000
. : milestone, 19202000,
iast_GLOBAL (18.043 s) : 18043000, 18043000
. : milestone, 18043000,
profiling (15.041 s) : 15041000, 15041000
. : milestone, 15041000,
tracing (15.074 s) : 15074000, 15074000
. : milestone, 15074000,
|
3512d83
to
c3ae681
Compare
Rewrite the algorithm for hoisting local vars: Go through all local vars defined in the method and determine by name all local var that are hoistable. local vars are hoistable if there is no conflict by slot or by name with another. If conflict by slot and same name we cancel hoisting for this name. if name is different we allocating a new slot for one of the local. If conflict by name and type are not compatible we cancel hoisting for this name. If type compatible, we can add in hoistable list. Then we are considering all hoistable variables by name and if there are multiple occurrence for a name, we are merging those variables in a new slot and rewrite var instructions to use this new slot. if only one variable we just assign a new slot and rewrite the instructions in the range.
c3ae681
to
7b3812f
Compare
varInsnNode.var = newSlot; | ||
} | ||
} | ||
if (insn instanceof IincInsnNode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this cover all the rewrite needed be done?
for example, while searching what iinc does, I found wide - which also can get variable index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wide
is very special instruction as this is a composite one. it modifies an existing instruction like iload
or iinc
to handle index more than 255 or incrementation > 128.
in ASM library decoding this instruction will result in either a VarInsnNode
or IIncInsnNode
because index are represented with int
anyway. It means that we are covering all instructions that way.
Here the handling of wide
instruction by ASM: https://github.com/llbit/ow2-asm/blob/a695934043d6f8f0aee3f6867c8dd167afd4aed8/src/org/objectweb/asm/ClassReader.java#L1066-L1073
newVarNode = hoistableVars.get(0); | ||
int oldIndex = newVarNode.index; | ||
newVarNode.index = newVar(getType(newVarNode.desc)); // new slot for the local variable | ||
rewriteLocalVarInsn(newVarNode, oldIndex, newVarNode.index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that matter. but it seems we are rewrite (assign new slot) for variables that we should not.
For every hoist-able variable, even if there is no collision we rewrite it and sign it to a new slot.
Maybe add a logic that would create find new slots only for variable only if there is a conflict to be solved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the LocalVariableTable is first optional, and then non-exhaustive. It does not prevent slot to be reused outside of what is declared in the LVT. By hoisting we extending the scope of the slot and we may conflict with another usage that we could not anticipated just by looking at the LVT. Here we are conservative and assign in any case a new slot that way we are isolating the variable for possible conflict outside of the LVT.
assertCaptureLocals(snapshot.getCaptures().getReturn(), "localVarL0", "int", "0"); | ||
assertCaptureLocals(snapshot.getCaptures().getReturn(), "localVarL1", "int", "1"); | ||
assertCaptureLocals(snapshot.getCaptures().getReturn(), "localVarL2", "int", "2"); | ||
assertCaptureLocals(snapshot.getCaptures().getReturn(), "localVarL3", "int", "3"); | ||
assertCaptureLocals(snapshot.getCaptures().getReturn(), "localVarL4", "int", "4"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why localVarL4 cannot be hoisted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
TestSnapshotListener listener = installProbes(CLASS_NAME, probe); | ||
Class<?> testClass = compileAndLoadClass(CLASS_NAME); | ||
int result = Reflect.onClass(testClass).call("main", "duplicateLocalDifferentScope").get(); | ||
assertEquals(28, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also asset 'ch' is not hoisted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
What Does This Do
Rewrite the algorithm for hoisting local vars:
Go through all local vars defined in the method and determine by name all local var that are hoistable.
local vars are hoistable if there is no conflict by slot or by name with another.
If conflict by slot and same name we cancel hoisting for this name. if
name is different we allocating a new slot for one of the local.
If conflict by name and type are not compatible we cancel hoisting for this name. If type compatible, we can add in hoistable list. Then we are considering all hoistable variables by name and if there are multiple occurrence for a name, we are merging those variables in a new slot and rewrite var instructions to use this new slot. if only one variable we just assign a new slot and rewrite the instructions in the range.
Motivation
Fixing issues since #7548
Additional Notes
Tested against exploration tests
Contributor Checklist
type:
and (comp:
orinst:
) labels in addition to any usefull labelsclose
,fix
or any linking keywords when referencing an issue.Use
solves
instead, and assign the PR milestone to the issueJira ticket: DEBUG-2841