JDK-8227060 : Optimize safepoint cleanup subtask order
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-07-02
  • Updated: 2022-07-25
  • Resolved: 2022-07-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20 b07Fixed
Related Reports
Relates :  
Description
The order in which safepoint cleanup subtasks are claimed and executed (by ParallelSPCleanupTask::work()) might not be optimal for minimizing the total time spent in the cleanup task.

Currently it first applies the ParallelSPCleanupThreadClosure to each thread, parallelized among the worker threads. Then each worker thread attempts to claim and execute a set of serial subtasks, in an order that might not have been chosen for optimiality.

Parallel worker threads working on the serial subtasks should attempt to claim them in order of decreasing expected duration.  Statically guessing an expected duration order for the serial subtasks might be good enough.  Alternatively, estimating their durations dynamically and sorting their claim ordering accordingly might be possible, at least for some.

If the per-thread durations for the thread cleanups are generally smaller than the larger serial subtask durations, and are reasonably balanced, it should be better to do the thread cleanups last.  However, a problem that can arise from that is that there might be a thread with a very large stack, and reaching it late in the iteration over the threads may significantly extend the total cleanup task time, with many workers idle at the end.  Stack size might be used to order the thread cleanups dynamically, possibly interleaved with the serial subtasks.

Comments
Changeset: 96a542fe Author: Coleen Phillimore <coleenp@openjdk.org> Date: 2022-07-19 16:32:07 +0000 URL: https://git.openjdk.org/jdk/commit/96a542feb2064dba155ebf05311752995d164038
19-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9515 Date: 2022-07-15 12:36:27 +0000
15-07-2022

With JDK-8246476 a thread is allocated to triggering the ServiceThread for async monitor deflation, which seems like it could be optimized to not be a separate cleanup task for a dedicated thread.
13-07-2020