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

Incorrect number of workers reported for reference processing

    XMLWordPrintable

    Details

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

      Description

      With `gc+phases+ref=debug`, the following log is generated using Parallel GC. Note that the number of non-strong refs is <1000 (default value of `ReferencesPerThread`), so only 1 worker should be used. However, it prints "Workers: 10" (10 is the #Parallel Workers).

      ```
      [3.284s][debug][gc,phases,ref] GC(0) Reconsider SoftReferences: 0.0ms
      [3.284s][debug][gc,phases,ref] GC(0) SoftRef (ms): skipped
      [3.284s][debug][gc,phases,ref] GC(0) Notify Soft/WeakReferences: 0.1ms
      [3.284s][debug][gc,phases,ref] GC(0) SoftRef (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0, Workers: 10
      [3.284s][debug][gc,phases,ref] GC(0) WeakRef (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1, Workers: 10
      [3.284s][debug][gc,phases,ref] GC(0) FinalRef (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0, Workers: 10
      [3.284s][debug][gc,phases,ref] GC(0) Total (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1, Workers: 10
      [3.284s][debug][gc,phases,ref] GC(0) Notify and keep alive finalizable: 0.0ms
      [3.284s][debug][gc,phases,ref] GC(0) FinalRef (ms): skipped
      [3.284s][debug][gc,phases,ref] GC(0) Notify PhantomReferences: 0.0ms
      [3.284s][debug][gc,phases,ref] GC(0) PhantomRef (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0, Workers: 10
      [3.284s][debug][gc,phases,ref] GC(0) SoftReference:
      [3.284s][debug][gc,phases,ref] GC(0) Discovered: 0
      [3.284s][debug][gc,phases,ref] GC(0) Cleared: 0
      [3.284s][debug][gc,phases,ref] GC(0) WeakReference:
      [3.284s][debug][gc,phases,ref] GC(0) Discovered: 348
      [3.284s][debug][gc,phases,ref] GC(0) Cleared: 220
      [3.284s][debug][gc,phases,ref] GC(0) FinalReference:
      [3.284s][debug][gc,phases,ref] GC(0) Discovered: 3
      [3.284s][debug][gc,phases,ref] GC(0) Cleared: 3
      [3.284s][debug][gc,phases,ref] GC(0) PhantomReference:
      [3.284s][debug][gc,phases,ref] GC(0) Discovered: 157
      [3.284s][debug][gc,phases,ref] GC(0) Cleared: 68
      ```

      Those lines are printed by `WorkerDataArray<T>::print_summary_on`, which has built-in logic for skipping "inactive" workers. However, when a single worker is used for ref processing, the "worker id", used by `WorkerDataArray` to decide which worker is active, is incorrect.

      In `ReferenceProcessor::run_task`, the else branch is for ref processing using a single thread (sequential case):

      ```
        if (processing_is_mt()) {
          ...
        } else {
          for (unsigned i = 0; i < _max_num_queues; ++i) {
            proxy_task.work(i); <--- here we are passing [0.._max_num_queues-1] as "worker id"
          }
        }
      ```

      This confuses WorkerDataArray to believe many workers are active in this subphase of ref-processing.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ayang Albert Yang
              Reporter:
              ayang Albert Yang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: