RFR: 8310428: Add CollectedHeap::reserved_range() API to return reserved heap memory range
Ioi Lam
iklam at openjdk.org
Thu Jun 22 03:05:03 UTC 2023
On Wed, 21 Jun 2023 15:30:17 GMT, Ashutosh Mehra <duke at openjdk.org> wrote:
> Please review this patch to add a new API `CollectedHeap::reserved_range()`. The changes are extracted out from https://github.com/openjdk/jdk/pull/14520 as per the suggestion [here](https://github.com/openjdk/jdk/pull/14520#discussion_r1234991165). Support for ZGC is not implemented yet as it can have discontiguous heap regions and unlike other collectors, it does not set `CollectedHeap::_reserved`.
For CDS, we actually don't need to know the exact range of the heap.
Currently, archive heap dumping is implemented only for G1. In the future, we want to be able to dump with any collector.
The eventual goal is - if you dump with collector X, then the layout of the archive heap should be optimal for this collector (e.g., avoid runtime relocation). The archive heap created by X should still be loadable by other collectors (but relocation is more likely).
So, for people who are really sensitive to start-up, they can create a custom archive with the specific GC that their app uses.
Currently, when dumping the archive heap with G1, we put it at the very top of the heap, which is the best location for G1 as this can usually avoid relocation. We determine the range by getting the entire G1 heap range, and take a portion of that from the top end.
To support all collectors, I think we can move the range calculation into each collector, and have a new API like
CollectorHeap::get_archive_heap_preferred_base(size_t required_bytes, size_t alignment);
The collector should return the range according to its policy. E.g., for SerialGC, it should probably return the bottom of the heap. The "reserve at heap top" logic can be moved into G1.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14595#issuecomment-1601950202
More information about the hotspot-dev
mailing list