Skip to content

8311163: Parallel: Improve large object handling during evacuation#20720

Closed
kimbarrett wants to merge 2 commits intoopenjdk:masterfrom
kimbarrett:parallelgc-partial-array-state
Closed

8311163: Parallel: Improve large object handling during evacuation#20720
kimbarrett wants to merge 2 commits intoopenjdk:masterfrom
kimbarrett:parallelgc-partial-array-state

Conversation

@kimbarrett
Copy link

@kimbarrett kimbarrett commented Aug 27, 2024

Please review this change to ParallelGC young generation collection's handling
of large objArrays, to now use the infrastructure provided by JDK-8253237 and
JDK-8337709. (That's the same infrastructure used by G1 young/mixed
collections.)

Testing: mach5 tier1-5


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8311163: Parallel: Improve large object handling during evacuation (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20720/head:pull/20720
$ git checkout pull/20720

Update a local copy of the PR:
$ git checkout pull/20720
$ git pull https://git.openjdk.org/jdk.git pull/20720/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20720

View PR using the GUI difftool:
$ git pr show -t 20720

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20720.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 27, 2024

👋 Welcome back kbarrett! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Aug 27, 2024

@kimbarrett This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8311163: Parallel: Improve large object handling during evacuation

Reviewed-by: tschatzl, ayang

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 105 new commits pushed to the master branch:

  • 92c4704: 8339166: java/lang/String/concat/HiddenClassUnloading.java fails on AIX and Linux ppc64le after JDK-8336856
  • 2abe2ff: 8339235: Fix indentation in build system
  • bb28b0d: 8338404: Cross-compilation to different endianness fails after JDK-8318913
  • b872718: 8338301: Error recovery and reporting should be improved for erroneous implicitly declared classes
  • b9e65f9: 8337662: Improve os::print_hex_dump for printing Instructions sections
  • f927c12: 8339154: Cleanups and JUnit conversion of test/jdk/java/util/zip/Available.java
  • 4675913: 8339237: RISC-V: Builds fail after JDK-8339120
  • b711c41: 8339196: Optimize BufWriterImpl#writeU1/U2/Int/Long
  • f2968b3: 8339020: Remove unused HeapShared::calculate_oopmap
  • a4962ac: 8338257: UTF8 lengths should be size_t not int
  • ... and 95 more: https://git.openjdk.org/jdk/compare/1ebf2cf639300728ffc024784f5dc1704317b0b3...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 27, 2024
@openjdk
Copy link

openjdk bot commented Aug 27, 2024

@kimbarrett The following label will be automatically applied to this pull request:

  • hotspot-gc

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Aug 27, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 27, 2024

Webrevs

@albertnetymk
Copy link
Member

albertnetymk commented Aug 27, 2024

Using -Xmx3g -XX:+UseParallelGC -XX:ParallelGCThreads=6 DelayInducer.java, I can see large regression on my box (nproc=12). Have you seen sth similar?

Old ``` # baseline [0.002s][info][gc] Using Parallel [1.252s][info][gc] GC(0) Pause Young (Allocation Failure) 381M->296M(479M) 50.696ms [1.490s][info][gc] GC(1) Pause Young (Allocation Failure) 422M->422M(674M) 165.177ms [1.864s][info][gc] GC(2) Pause Young (Allocation Failure) 673M->674M(925M) 212.106ms [2.243s][info][gc] GC(3) Pause Young (Allocation Failure) 925M->925M(1428M) 229.982ms

new

[0.005s][info][gc] Using Parallel
[5.504s][info][gc] GC(0) Pause Young (Allocation Failure) 381M->299M(479M) 203.409ms
[6.233s][info][gc] GC(1) Pause Young (Allocation Failure) 424M->425M(676M) 620.718ms
[7.594s][info][gc] GC(2) Pause Young (Allocation Failure) 676M->676M(928M) 1155.301ms
[8.920s][info][gc] GC(3) Pause Young (Allocation Failure) 927M->928M(1430M) 1119.259ms

<details>

@albertnetymk
Copy link
Member

Using -Xmx3g -XX:+UseParallelGC -XX:ParallelGCThreads=6 DelayInducer.java, I can see some regression (~10%) in avg gc-pause time on my box (nproc=12). Have you seen sth similar?

# baseline
[0.003s][info][gc] Using Parallel
[1.175s][info][gc] GC(0) Pause Young (Allocation Failure) 381M->299M(479M) 53.655ms
[1.432s][info][gc] GC(1) Pause Young (Allocation Failure) 424M->425M(676M) 185.065ms
[1.821s][info][gc] GC(2) Pause Young (Allocation Failure) 676M->676M(928M) 234.141ms
[2.171s][info][gc] GC(3) Pause Young (Allocation Failure) 927M->928M(1430M) 206.027ms
[7.367s][info][gc] GC(4) Pause Young (Allocation Failure) 1814M->1809M(2312M) 631.159ms
[8.217s][info][gc] GC(5) Pause Full (Allocation Failure) 2311M->732M(2105M) 547.506ms
[10.453s][info][gc] GC(6) Pause Young (Allocation Failure) 1074M->1068M(2105M) 162.718ms
[11.581s][info][gc] GC(7) Pause Young (Allocation Failure) 1410M->994M(2105M) 157.642ms
[12.400s][info][gc] GC(8) Pause Young (Allocation Failure) 1336M->926M(2105M) 114.424ms


# new
[0.002s][info][gc] Using Parallel
[1.176s][info][gc] GC(0) Pause Young (Allocation Failure) 381M->299M(479M) 59.968ms
[1.415s][info][gc] GC(1) Pause Young (Allocation Failure) 425M->425M(676M) 167.393ms
[1.771s][info][gc] GC(2) Pause Young (Allocation Failure) 676M->676M(928M) 199.576ms
[2.151s][info][gc] GC(3) Pause Young (Allocation Failure) 927M->928M(1430M) 236.868ms
[7.397s][info][gc] GC(4) Pause Young (Allocation Failure) 1814M->1809M(2312M) 689.166ms
[8.299s][info][gc] GC(5) Pause Full (Allocation Failure) 2311M->732M(2106M) 603.035ms
[10.560s][info][gc] GC(6) Pause Young (Allocation Failure) 1074M->1068M(2106M) 218.286ms
[11.710s][info][gc] GC(7) Pause Young (Allocation Failure) 1410M->994M(2106M) 183.299ms
[12.590s][info][gc] GC(8) Pause Young (Allocation Failure) 1336M->926M(2106M) 181.675ms

@kimbarrett
Copy link
Author

Using -Xmx3g -XX:+UseParallelGC -XX:ParallelGCThreads=6 DelayInducer.java, I can see some regression (~10%) in avg gc-pause time on my box (nproc=12). Have you seen sth similar?

No, I'm not seeing anything like that. Indeed, I'm seeing strongly the
opposite. Note that my machine has nproc=32, but the results were similar with
-XX:ActiveProcessorCount=12.

old
[1.966s][info][gc] GC(0) Pause Young (Allocation Failure) 504M->387M(1930M) 744.238ms
[2.446s][info][gc] GC(1) Pause Young (Allocation Failure) 891M->882M(2283M) 236.505ms
[7.733s][info][gc] GC(2) Pause Young (Allocation Failure) 1686M->1669M(2668M) 1678.807ms
[9.423s][info][gc] GC(3) Pause Full (Allocation Failure) 2523M->89M(2421M) 45.843ms

new
[1.694s][info][gc] GC(0) Pause Young (Allocation Failure) 504M->397M(1930M) 469.406ms
[2.140s][info][gc] GC(1) Pause Young (Allocation Failure) 901M->892M(2283M) 224.942ms
[6.533s][info][gc] GC(2) Pause Young (Allocation Failure) 1682M->1669M(2668M) 761.521ms
[8.253s][info][gc] GC(3) Pause Full (Allocation Failure) 2509M->89M(2408M) 47.130ms

These results are pretty stable across 10-12 runs. Regardless of which variant
is used, the number and types of GCs is stable, as are the collection amounts.
And for a given variant the times are fairly stable.

For GC(0), the new variant is consistently faster, though the fastest old time
and the slowest new time are close or overlap.

For GC(1), the two variants are pretty similar.

For GC(2), the new variant is consistently more than a factor of 2 faster, and
the average difference is closer to 2.5x.

Digging a bit deeper, here are sample times for the Scavenge phase.

old
[7.849s][debug][gc,phases      ] GC(2) Scavenge 1928.903ms
new
[6.511s][debug][gc,phases      ] GC(2) Scavenge 774.372ms

I haven't found a way to get more detailed timing information there. In
particular, I thought there was some logging in the TaskTerminator, but don't
see any now.

I rebuilt the variants with -DTASKQUEUE_STATS and ran with gc+task+stats=trace
logging, and here's a sample output:

[6.610s][trace][gc,task,stats] GC(2) thr       push      steal    chunked     chunks
[6.610s][trace][gc,task,stats] GC(2) --- ---------- ---------- ---------- ----------
[6.610s][trace][gc,task,stats] GC(2)   0     306340          0         19     306335
[6.610s][trace][gc,task,stats] GC(2)   1     300040          2          7     300041
[6.610s][trace][gc,task,stats] GC(2)   2     303588          1          0     303589
[6.610s][trace][gc,task,stats] GC(2)   3     334770          3          0     334771
[6.610s][trace][gc,task,stats] GC(2)   4     332980          3          0     332981
[6.610s][trace][gc,task,stats] GC(2)   5     436049          1          0     436050

new
[6.657s][trace][gc,task,stats] GC(2)     ----partial array----     arrays      array
[6.657s][trace][gc,task,stats] GC(2) thr       push      steal    chunked     chunks
[6.658s][trace][gc,task,stats] GC(2) --- ---------- ---------- ---------- ----------
[6.658s][trace][gc,task,stats] GC(2)   0     315502          2         18     315503
[6.658s][trace][gc,task,stats] GC(2)   1     314152          1          0     314153
[6.658s][trace][gc,task,stats] GC(2)   2     321092          2          7     321093
[6.658s][trace][gc,task,stats] GC(2)   3     406893          4          0     406893
[6.658s][trace][gc,task,stats] GC(2)   4     326710          1          0     326707
[6.658s][trace][gc,task,stats] GC(2)   5     329418          1          1     329418

The number of partial array steals is about the same.

So I don't yet know why the change is so beneficial for GC(2).

@tschatzl
Copy link
Contributor

I did some runs with 1, 2, 4, 6, 12 and 25 parallel workers and I can't see regressions either; the changes seem to be better always. The only difference from your runs is that with -Xmx3g there are in total four young collections every time. The last one is the one showing the 2x+ speedup.

@tschatzl
Copy link
Contributor

The old code seems to only ever push a single continuation task, while the new code pushes multiple (after the first one), and tries to keep them at ParallelGCThreads.

@albertnetymk
Copy link
Member

Using another box (AMD), the improvement becomes clear.

## baesline

[0.003s][info][gc] Using Parallel
[1.464s][info][gc] GC(0) Pause Young (Allocation Failure) 512M->344M(1963M) 586.065ms
[2.163s][info][gc] GC(1) Pause Young (Allocation Failure) 857M->853M(2304M) 298.110ms
[8.208s][info][gc] GC(2) Pause Young (Allocation Failure) 1707M->1669M(2689M) 2986.103ms
[9.941s][info][gc] GC(3) Pause Full (Allocation Failure) 2516M->91M(2485M) 38.478ms

## new
[0.002s][info][gc] Using Parallel
[1.325s][info][gc] GC(0) Pause Young (Allocation Failure) 512M->355M(1963M) 415.916ms
[1.791s][info][gc] GC(1) Pause Young (Allocation Failure) 867M->858M(2304M) 212.690ms
[5.663s][info][gc] GC(2) Pause Young (Allocation Failure) 1700M->1669M(2689M) 821.355ms
[7.088s][info][gc] GC(3) Pause Full (Allocation Failure) 2510M->91M(2475M) 32.170ms

So I don't yet know why the change is so beneficial for GC(2).

With -Xlog:gc*=debug, I can see an expansion during GC(2) -- I guess because the expansion operation is synchronous, not having any chunks in the task-queue essentially blocks other workers.

_partial_array_state_allocator->release(_partial_array_state_allocator_index, state);
}

void PSPromotionManager::push_objArray(oop old_obj, oop new_obj, size_t obj_size) {
Copy link
Member

Choose a reason for hiding this comment

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

obj_size seems unused.

Copy link
Author

Choose a reason for hiding this comment

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

I'd originally intended to compute the array_length from this argument, but that's kind of messy so I went
with the simpler approach of just fetching it from one of the objects. I've removed the argument.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 29, 2024
Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

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

lgtm

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 30, 2024
Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

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

Still good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 30, 2024
@kimbarrett
Copy link
Author

Thanks for reviews @albertnetymk and @tschatzl

@kimbarrett
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Aug 31, 2024

Going to push as commit 4f071ce.
Since your change was applied there have been 111 commits pushed to the master branch:

  • b840b13: 8338882: Clarify matching order of MessageFormat subformat factory styles
  • 25e03b5: 8339115: Rename TypeKind enum constants to follow code style
  • fef1ef7: 6426678: (spec) File.createTempFile(prefix, suffix, dir) needs clarification for illegal symbols in suffix
  • a528c4b: 8339156: Use more fine-granular clang unused warnings
  • 2fb8305: 8339319: ProblemList runtime/exceptionMsgs/NoClassDefFoundError/NoClassDefFoundErrorTest.java
  • 3a352b8: 8339191: JFR: Bulk read support for ChunkInputStream
  • 92c4704: 8339166: java/lang/String/concat/HiddenClassUnloading.java fails on AIX and Linux ppc64le after JDK-8336856
  • 2abe2ff: 8339235: Fix indentation in build system
  • bb28b0d: 8338404: Cross-compilation to different endianness fails after JDK-8318913
  • b872718: 8338301: Error recovery and reporting should be improved for erroneous implicitly declared classes
  • ... and 101 more: https://git.openjdk.org/jdk/compare/1ebf2cf639300728ffc024784f5dc1704317b0b3...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 31, 2024
@openjdk openjdk bot closed this Aug 31, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 31, 2024
@openjdk
Copy link

openjdk bot commented Aug 31, 2024

@kimbarrett Pushed as commit 4f071ce.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kimbarrett kimbarrett deleted the parallelgc-partial-array-state branch August 31, 2024 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants