Skip to content

8377137: Support large CDS archives with UseCompactObjectHeaders#29556

Closed
XueleiFan wants to merge 6 commits intoopenjdk:masterfrom
XueleiFan:JDK-8377137
Closed

8377137: Support large CDS archives with UseCompactObjectHeaders#29556
XueleiFan wants to merge 6 commits intoopenjdk:masterfrom
XueleiFan:JDK-8377137

Conversation

@XueleiFan
Copy link
Member

@XueleiFan XueleiFan commented Feb 4, 2026

The Core Problem

With UseCompactObjectHeaders, each Java object header contains a 22-bit narrow Klass ID (plus 10-bit shift), limiting the Klass encoding range to 4GB. CDS archives store pre-computed narrow Klass IDs in:

  • Archived heap object headers
  • Klass prototype headers (templates for new object allocation)

Two issues arise:

  1. Size limit: Large archives (>4GB) cannot fit within the encoding range
  2. Address relocation: When ASLR maps the archive at a different address, pre-computed narrow Klass IDs become invalid

Key Insight

Only Klass objects need narrow Klass encoding — they are referenced from object headers via 22-bit IDs. Other metadata (Methods, ConstantPools, Symbols, etc.) are accessed through regular 64-bit pointers and can reside anywhere in memory.

Solution: Two-Part Approach

Part 1: Klass Region Separation (Dump Time)

Logically separate Klass objects from other metadata:

  • Place all Klass objects at the start of the archive's RW region
  • Track the Klass region size in the archive header
  • Only the Klass region (not the entire archive) must fit within 4GB

This allows archives to grow beyond 4GB while keeping Klasses within the encoding range.

Part 2: Narrow Klass ID Remapping (Load Time)

When the archive is mapped at a different address than requested:

  • The narrow Klass encoding parameters (base address, shift) may differ between dump-time and runtime
  • Pre-computed narrow Klass IDs no longer decode to correct Klass addresses
  • Remap all narrow Klass IDs from dump-time encoding to runtime encoding

The remapping formula:

dump_klass_addr = dump_base + (dump_nk << shift)
runtime_klass_addr = dump_klass_addr + relocation_delta
runtime_nk = (runtime_klass_addr - runtime_base) >> shift

Memory Layout

For large archives, use split encoding mode where class space is placed before the archive:

Normal (small archive):   [archive]───[gap]───[class_space]
                          ↑ encoding base

Split (large archive):    [class_space]───[gap]───[archive]
                          ↑ encoding base          ↑ only Klass region
                                                     must reach here

This maximizes the usable encoding range by starting from class_space and only requiring the Klass region (not the entire archive) to be reachable.

Result

  • Archives up to ~32GB can be supported (limited only by Klass region fitting in 4GB)
  • Transparent to application code — remapping happens during JVM startup
  • No performance impact on steady-state execution

Parallel Narrow Klass ID Patching

Added parallel patching of narrow Klass IDs in archived heap objects during AOT cache loading, following the same ArchiveWorkerTask pattern used by SharedDataRelocationTask. Pre-computes object boundaries at chunk splits, then workers process their ranges in parallel.

Benchmark (3.4GB archive): 1.85x speedup for relocation (189ms vs 350ms), 1.24x overall startup improvement (662ms vs 535ms), by using 3 threads on 12-core machine


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8377137: Support large CDS archives with UseCompactObjectHeaders (Enhancement - P3) ⚠️ Issue is not open.

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/29556/head:pull/29556
$ git checkout pull/29556

Update a local copy of the PR:
$ git checkout pull/29556
$ git pull https://git.openjdk.org/jdk.git pull/29556/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 29556

View PR using the GUI difftool:
$ git pr show -t 29556

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/29556.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 4, 2026

👋 Welcome back xuelei! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 4, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Feb 4, 2026
@openjdk
Copy link

openjdk bot commented Feb 4, 2026

@XueleiFan The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@XueleiFan XueleiFan changed the title 8377137: archive with compact object headers 8377137: Support large CDS archives with UseCompactObjectHeaders Feb 4, 2026
@XueleiFan XueleiFan closed this Feb 5, 2026
@XueleiFan XueleiFan reopened this Feb 6, 2026
@XueleiFan XueleiFan closed this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

1 participant