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

Make Metaspace ChunkManager counters non-atomic

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 10
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b21

      Description

      In metaspace.cpp, ChunkManager keeps counters for the number of free chunks in all its free lists (_free_chunks_count) and combined size of all these chunks (_free_chunks_total). These counters are updated using Atomics.

      Supposedly because atomic updates are expensive, updates are delayed as much as possible. When returning chunks to the free list, instead of updating the counter for every returned chunk, the counter is updated for all chunks at once (~SpaceManager). This introduces time windows where the counters do not reflect the real state of the freelist, which makes it difficult to verify the internal state of the ChunkManager.

      The counters do not have to be updated atomically, because all accesses happen under lock protection. So the updates can be moved closer to the chunk return point and the window where counters are invalid almost disappears, making the code easier.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stuefe Thomas Stuefe
                Reporter:
                stuefe Thomas Stuefe
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: