RFR: JDK-8255885: Metaspace: freelist commit counter is not updated when purging

Thomas Stuefe stuefe at openjdk.java.net
Thu Nov 19 20:50:04 UTC 2020


On Thu, 19 Nov 2020 19:32:45 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> This seems good and more accurate to recalculate the size committed in each chunk by iterating through the chunks.

Thank you!

> For path 2 in your description, for Metaspace::purge() I thought that chunks are returned to the ChunkFreeList from the ChunkList on each metaspace. So they should be accounted for. Or is the issue that committed_words within each chunk varies and remove() only captures a snapshot in time? 

Yes. We return chunks via this path:

`~CLD -> ~ClassLoaderMetaspace -> ~MetaspaceArena -> (for each chunk) ChunkManager::return_chunk() -> .. -> FreeChunkList::add().` (a)

Here, FreeChunkList::_committed_words gets updated from the added chunk's _committed_words.

But chunks can be committed and uncommitted from anywhere really, and the containing list would not notice. This can happen in several places, one of which is when metaspace is purged some cylces later in (b) path 2:

https://github.com/openjdk/jdk/blob/080c707aabcf1b2ed30009cb408ecf52bd1784fd/src/hotspot/share/memory/metaspace/chunkManager.cpp#L346

which uncommits chunks and the freelist would not notice. Rather than introduce some elaborate counter update mechanism, I just remove it.

> At any rate, it's good to not have this in the logging and printing if it's going to be expensive but accurate.

Yes I think so too. 

Thanks, Thomas

-------------

PR: https://git.openjdk.java.net/jdk/pull/1057


More information about the hotspot-runtime-dev mailing list