RFR: 8367754: G1: Add a fast path in heap resize related method
Guanqiang Han
ghan at openjdk.org
Wed Sep 17 15:45:15 UTC 2025
Please review this change.
**Description:**
It's common for some Java application engineers to configure the heap with the same minimum and maximum size in order to avoid the overhead of heap resizing.In such cases no expansion or shrinkage is possible, so i think we can adds a fast path at the beginning of the method to detect when the heap’s min and max capacities are equal and return early, thereby avoiding unnecessary computation.
I added a check to determine whether MinHeapSize and MaxHeapSize are equal before performing the heap resize calculation. Since both MaxHeapSize and MinHeapSize are aligned to HeapAlignment, so i think comparing them directly is good.
**Test:**
GHA
-------------
Commit messages:
- Implement fast path
Changes: https://git.openjdk.org/jdk/pull/27349/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27349&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8367754
Stats: 23 lines in 3 files changed: 22 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/27349.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27349/head:pull/27349
PR: https://git.openjdk.org/jdk/pull/27349
More information about the hotspot-gc-dev
mailing list