Skip to content

Commit

Permalink
Report loop counts in interpreter and first tier
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Nov 29, 2021
1 parent 1510dd3 commit afbf57b
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ public Object execute(final VirtualFrame frame, final int startPC) {
private Object interpretBytecode(final VirtualFrame frame, final int startPC) {
CompilerAsserts.partialEvaluationConstant(bytecodeNodes.length);
int pc = startPC;
int backJumpCounter = 0;
/*
* Maintain backJumpCounter in an int[] so that the compiler does not confuse it with the
* basicBlockIndex because both are constant within the loop.
*/
final int[] backJumpCounter = new int[1];
Object returnValue = null;
bytecode_loop: while (pc != LOCAL_RETURN_PC) {
CompilerAsserts.partialEvaluationConstant(pc);
Expand Down Expand Up @@ -121,8 +125,8 @@ private Object interpretBytecode(final VirtualFrame frame, final int startPC) {
}
} else if (node instanceof UnconditionalJumpNode) {
final int successor = ((UnconditionalJumpNode) node).getSuccessorIndex();
if (CompilerDirectives.inInterpreter() && successor <= pc && backJumpCounter < Integer.MAX_VALUE) {
backJumpCounter++;
if (CompilerDirectives.hasNextTier() && successor <= pc) {
backJumpCounter[0]++;
}
pc = successor;
continue bytecode_loop;
Expand All @@ -139,8 +143,9 @@ private Object interpretBytecode(final VirtualFrame frame, final int startPC) {
}
assert returnValue != null && !FrameAccess.hasModifiedSender(frame);
FrameAccess.terminate(frame);
if (backJumpCounter != 0) {
LoopNode.reportLoopCount(this, backJumpCounter > 0 ? backJumpCounter : Integer.MAX_VALUE);
// only report non-zero counters to reduce interpreter overhead
if (CompilerDirectives.hasNextTier() && backJumpCounter[0] != 0) {
LoopNode.reportLoopCount(this, backJumpCounter[0] > 0 ? backJumpCounter[0] : Integer.MAX_VALUE);
}
return returnValue;
}
Expand Down

2 comments on commit afbf57b

@TruffleSqueak-Bot
Copy link

Choose a reason for hiding this comment

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

Performance Report (afbf57b)

Benchmarks ran on graalvm-ce-java11-22.1.0-dev.

Steady (after 50 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 182 276 187.54 183 186.88 37508 0.63
DeltaBlue 333 518 455.1 454 454.7 91019 1.52
Havlak 1729 1845 1800.37 1814 1800.16 360074 6
Json 933 981 944.68 942 944.65 188936 3.15
List 512 608 516.48 512 516.21 103296 1.72
Mandelbrot 144 167 145.39 145 145.36 29077 0.48
NBody 576 673 584.47 579 584.36 116894 1.95
Permute 232 268 234.4 233 234.33 46880 0.78
Queens 258 303 262.9 260 262.75 52579 0.88
Richards 1101 1138 1106.51 1103 1106.48 221301 3.69
Sieve 214 252 216.15 214.5 216.06 43230 0.72
Storage 287 331 291.31 288 291.22 58261 0.97
Towers 348 379 350.71 349 350.66 70142 1.17
6849 7739 7095.99 7076.5 7093.82 1419197 23.65

afbf57b-2-steady.svg

Warmup (first 50 iterations)

afbf57b-3-warmup.svg

@TruffleSqueak-Bot
Copy link

Choose a reason for hiding this comment

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

Performance Report (afbf57b)

Benchmarks ran on graalvm-ce-java11-22.1.0-dev.

Steady (after 50 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 182 208 183.77 183 183.75 36754 0.61
DeltaBlue 358 519 459.5 458 459.22 91899 1.53
Havlak 1733 1873 1801.77 1814 1801.55 360354 6.01
Json 925 980 934.26 930 934.21 186851 3.11
List 509 613 516.72 511 516.27 103343 1.72
Mandelbrot 144 176 145.68 145 145.62 29136 0.49
NBody 577 622 583.36 580 583.31 116672 1.94
Permute 233 272 236.39 234 236.29 47277 0.79
Queens 254 321 262.74 257 262.41 52547 0.88
Richards 1084 1132 1088.43 1085 1088.4 217685 3.63
Sieve 214 255 215.74 215 215.69 43148 0.72
Storage 290 326 293.12 290 293.05 58624 0.98
Towers 369 414 373.09 372 373.06 74618 1.24
6872 7711 7094.54 7074 7092.83 1418908 23.65

afbf57b-2-steady.svg

Warmup (first 50 iterations)

afbf57b-3-warmup.svg

Please sign in to comment.