On Tue, 27 Oct 2026 14:46:44 GMT, Andrew Haley <[email protected]> wrote:

>> Please use [this 
>> link](https://github.com/openjdk/jdk/pull/28541/changes?w=1) to view the 
>> files changed.
>> 
>> Profile counters scale very badly.
>> 
>> The overhead for profiled code isn't too bad with one thread, but as the 
>> thread count increases, things go wrong very quickly.
>> 
>> For example, here's a benchmark from the OpenJDK test suite, run at 
>> TieredLevel 3 with one thread, then three threads:
>> 
>> 
>> Benchmark (randomized) Mode Cnt Score Error Units
>> InterfaceCalls.test2ndInt5Types false avgt 4 27.468 ± 2.631 ns/op
>> InterfaceCalls.test2ndInt5Types false avgt 4 240.010 ± 6.329 ns/op
>> 
>> 
>> This slowdown is caused by high memory contention on the profile counters. 
>> Not only is this slow, but it can also lose profile counts.
>> 
>> This patch is for C1 only. It'd be easy to randomize interpreter counters as 
>> well in another PR, if anyone thinks it's worth doing.
>> 
>> One other thing to note is that randomized profile counters degrade very 
>> badly with small decimation ratios. For example, using a ratio of 2 with 
>> `-XX:ProfileCaptureRatio=2` with a single thread results in
>> 
>> 
>> Benchmark                        (randomized)  Mode  Cnt   Score   Error  
>> Units
>> InterfaceCalls.test2ndInt5Types         false  avgt    4  80.147 ± 9.991  
>> ns/op
>> 
>> 
>> The problem is that the branch prediction rate drops away very badly, 
>> leading to many mispredictions. It only really makes sense to use higher 
>> decimation ratios, e.g. 64.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Andrew Haley has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 234 commits:
> 
>  - Merge from master.
>  - More
>  - Merge branch 'JDK-8134940' of https://github.com/theRealAph/jdk into 
> JDK-8134940
>  - Remove debug helpers
>  - Remove debug helpers
>  - Whitespace
>  - Back out some lily gilding.
>  - More
>  - seems to work
>  - Fix LIRGenerator::profile_branch to use const offsets.
>  - ... and 224 more: https://git.openjdk.org/jdk/compare/7ae0f1f5...41c5da16

I've done some more work, and the single-thread performance with randomized 
counters is now very similar to baseline, with the difference almost at the 
noise level. Inevitably there is some code expansion, because we have to check 
the random-number and ten generate the increment.

@shipilev , do you agree that we should ask now for more reviewers?


 $ OPTS= 
J_HP=$HOME/theRealAph-jdk/build/linux-aarch64-server-release/images/jdk sh 
./run-renaissance.sh.1 dotty -r 20
  -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
dotty -r 20

--- Patched, PCR=1
Run 1: 4904 1626 1215 898 766 687 613 584 559 520 505 494 476 455 455 437 421 
433 416 397 
Run 2: 4659 1483 1002 852 746 663 610 570 542 526 493 484 492 450 455 433 434 
414 404 415 
Run 3: 4600 1439 1075 861 774 686 622 585 549 529 514 496 477 468 452 422 423 
416 406 409 

Tier1: 0.078 s, 9796 bytes, 2145 methods;
Tier2: 2.119 s, 979378 bytes, 4780 methods;
Tier3: 7.917 s, 2463261 bytes, 13761 methods;
Tier4: 45.539 s, 6215982 bytes, 6482 methods;

Uncommon traps hit: 463


--- Patched, PCR=64
Run 1: 4653 1498 1060 864 743 672 616 572 583 513 484 488 459 456 427 437 434 
426 404 393 
Run 2: 4672 1497 1047 875 761 668 612 572 533 510 490 483 456 451 423 415 416 
416 412 408 
Run 3: 4806 1498 1074 878 757 684 612 562 533 509 489 481 463 450 442 429 404 
414 405 408 

Tier1: 0.078 s, 9840 bytes, 2155 methods;
Tier2: 2.004 s, 919120 bytes, 4754 methods;
Tier3: 8.392 s, 2528575 bytes, 13868 methods;
Tier4: 45.042 s, 6197468 bytes, 6553 methods;

Uncommon traps hit: 471


--- Patched, PCR=128
Run 1: 4668 1516 1073 878 776 686 616 569 542 511 495 485 465 469 422 426 423 
417 413 411 
Run 2: 4637 1482 1017 853 757 679 613 561 539 520 496 493 458 439 439 435 411 
420 401 403 
Run 3: 4614 1483 1071 898 789 668 606 570 547 524 496 482 455 450 435 424 427 
404 405 399 

Tier1: 0.083 s, 9816 bytes, 2150 methods;
Tier2: 2.130 s, 1083407 bytes, 5406 methods;
Tier3: 8.293 s, 2501333 bytes, 13606 methods;
Tier4: 44.539 s, 6073878 bytes, 6453 methods;

Uncommon traps hit: 470

-------------

PR Comment: https://git.openjdk.org/jdk/pull/28541#issuecomment-6446783981

Reply via email to