JDK-8273482 : Remove "foreground work" concept from WorkGang
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-09-08
  • Updated: 2021-10-15
  • Resolved: 2021-09-10
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 18
18 b15Fixed
Related Reports
Relates :  
Relates :  
Description
JDK-8237354 introduced the concept of "foreground work" in WorkGang, as a special case for use by the HeapDumper. I propose that we remove this code, since this special use case can be solved without the need for the concept of "foreground work" in WorkGang.

As far as I can tell, there's no reason why it must be the VM thread that takes on the task of writing the header, iterating over roots, etc. So, in VM_HeapDumper::work(), instead of checking if the current thread is the VM thread we can just check if the worker_id is non-zero. That way, a single worker thread will take on the task of writing the header, iterating over roots, etc, and all other worker threads will continue to call worker_loop().

Something like this:

diff --git a/src/hotspot/share/services/heapDumper.cpp b/src/hotspot/share/services/heapDumper.cpp
index ac5294aa2bd..0d3cfbd99d7 100644
--- a/src/hotspot/share/services/heapDumper.cpp
+++ b/src/hotspot/share/services/heapDumper.cpp
@@ -1771,7 +1771,7 @@ void VM_HeapDumper::doit() {
   if (gang == NULL) {
     work(0);
   } else {
-    gang->run_task(this, gang->active_workers(), true);
+    gang->run_task(this);
   }
 
   // Now we clear the global variables, so that a future dumper can run.
@@ -1780,7 +1780,7 @@ void VM_HeapDumper::doit() {
 }
 
 void VM_HeapDumper::work(uint worker_id) {
-  if (!Thread::current()->is_VM_thread()) {
+  if (worker_id != 0) {
     writer()->writer_loop();
     return;
   }

Comments
Changeset: c1e39faa Author: Per Liden <pliden@openjdk.org> Date: 2021-09-10 09:49:45 +0000 URL: https://git.openjdk.java.net/jdk/commit/c1e39faaa99ee62ff626ffec9f978ed0f8ffaca1
10-09-2021