RFR: JDK-8303051: Stop saving 5 chunks in each ChunkPool [v4]

Johan Sjölen jsjolen at openjdk.org
Thu Feb 23 16:13:43 UTC 2023


On Thu, 23 Feb 2023 15:10:51 GMT, Justin King <jcking at openjdk.org> wrote:

> I question whether we should be saving any chunks at all in a central cache. Most malloc have per thread caches. By allocating in one thread and freeing in another thread whose sole purpose is deallocation we are kind of defeating the per thread caches purpose.
> 
> We should benchmark just removing the cache entirely in the future. In the distant past this could have been useful, but I question it now.

This was my intuition too :-). I tried removing the ChunkPool but my (very basic) experiments showed that this is in fact slower.  Note that this chunk cache is shared across the whole program, so checking whether there is a free chunk requires grabbing a mutex. We see a large increase in mallocs early in the lifetime of a program if it's entirely removed, and this happened to outpace the cost of holding a mutex. So the non-benefit of the `ChunkPool` wasn't trivial to prove. Apparently CDS complicates the situation more.

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

PR: https://git.openjdk.org/jdk/pull/12710


More information about the hotspot-runtime-dev mailing list