Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8273482

Remove "foreground work" concept from WorkGang

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      gc
    • Resolved In Build:
      b15

      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;
         }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pliden Per Liden
              Reporter:
              pliden Per Liden
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: