RFR: 8367332: Replace BlockTree tree logic with an intrusive red-black tree [v2]
Casper Norrbin
cnorrbin at openjdk.org
Fri Dec 12 15:49:20 UTC 2025
> Hi everyone,
>
> Metaspace's `BlockTree` is currently implemented as a simple binary search tree, using the memory blocks it stores as the nodes. While this is straightforward and generally fine, it can become unbalanced depending on insert/remove order, leading to degraded performance.
>
> This is a good fit for the utilities `IntrusiveRBTree`, instead of using internal tree logic. With it, we can replace all tree functions and instead rely on a few insert/remove calls. `BlockTree` still remains as the layer coordinating these blocks, and still handles the list of same-size nodes. The intrusive red-black tree only handles balancing and linking/unlinking nodes in the tree structure.
>
> Validation and printing are preserved by using the hooks provided by the red-black tree. We keep the same checks (and get a few more from the rb-tree), and the printed output is kept identical. The only real difference is that the red-black tree traverses the tree instead.
>
> Testing:
> - Oracle tiers 1-8
Casper Norrbin has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
- Merge branch 'master' into blocktree-intrusive
- Merge branch 'master' into blocktree-intrusive
- moved blocktree tree logic to intrusive rbtree
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/27212/files
- new: https://git.openjdk.org/jdk/pull/27212/files/b74c1e18..fd0571a0
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=27212&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=27212&range=00-01
Stats: 571881 lines in 5817 files changed: 397102 ins; 110724 del; 64055 mod
Patch: https://git.openjdk.org/jdk/pull/27212.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27212/head:pull/27212
PR: https://git.openjdk.org/jdk/pull/27212
More information about the hotspot-runtime-dev
mailing list