RFR: JDK-8276086: Increase size of metaspace mappings

Thomas Stuefe stuefe at openjdk.java.net
Thu Oct 28 13:05:24 UTC 2021

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:


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.


- manual gtests + metaspace jtreg tests (32bit and 64bit)
- GHAs scheduled
- SAP nightlies scheduled


Commit messages:
 - start

Changes: https://git.openjdk.java.net/jdk/pull/6148/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6148&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8276086
  Stats: 8 lines in 2 files changed: 0 ins; 1 del; 7 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6148.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6148/head:pull/6148

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

More information about the hotspot-runtime-dev mailing list