RFR: JDK-8276086: Increase size of metaspace mappings

Goetz Lindenmaier goetz at openjdk.java.net
Fri Oct 29 07:23:16 UTC 2021


On Thu, 28 Oct 2021 07:00:16 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Disregarding class space, metaspace consists of a list of individual mappings. Traditionally, individual mappings had been rather small (2 root chunks => 8 MB). That is because the mechanism to release metaspace memory to the OS had been to unmap unused mappings, and the larger the mappings were the smaller the chance of them being completely unused, due to fragmentation.
> 
> We recently did away with this old release mechanism in favor of a new one with finer granularity (see https://bugs.openjdk.java.net/browse/JDK-8275582). So there is no motivation anymore to keep mappings particularly small.
> 
> There are however good reasons to enlarge them:
> - less fragmentation on the OS mapping level (e.g. on Linux, number of VMAs would go down, has a number of advantages)
> - Larger mappings -> fewer of them -> list gets smaller, which is good for functions iterating this list (e.g. `Metaspace::contains()`, see https://bugs.openjdk.java.net/browse/JDK-8275704).
> 
> The effect of larger mappings is an increase in the step size with process *virtual size* will grow. So, before vsize grew in 8MB steps, now those steps are larger and rarer. In total we should not use much more vsize than before. Larger mappings would have no effect on committed memory size.
> 
> And note that vsize is pretty much irrelevant with modern OSes. For our hotspot on 64-bit, it is astronomical anyway, so this change would have no impact in real life.
> 
> The only exception are 32-bit platforms, where address space itself is limited, so this change is limited to 64-bit.
> 
> ----
> 
> How it looks after loading 3000 classes:
> 
> 64-bit:
> 
> 
> Virtual space:                                                                       
>   Non-class space:      384,00 MB reserved,     338,94 MB ( 88%) committed,  6 nodes.
>       Class space:        1,00 GB reserved,      13,00 MB (  1%) committed,  1 nodes.
>              Both:        1,38 GB reserved,     351,94 MB ( 25%) committed.          
> 
> 
> 32-bit  (note: no class space, smaller data):
> 
> 
> Virtual space:                                                    
>     248,00 MB reserved,     242,00 MB ( 98%) committed,  31 nodes.
> 
> 
> ----
> 
> Tests:
> - manual gtests + metaspace jtreg tests (32bit and 64bit)
> - GHAs 
> - SAP nightlies

Hi Thomas, why did you choose 64MB for the new size?

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

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


More information about the hotspot-runtime-dev mailing list