Automatically reduce heap size near compressed oops limit
Gillespie, Oli
ogillesp at amazon.co.uk
Mon Nov 13 12:47:16 UTC 2023
Hi,
It's quite easy to make a mistake when configuring heap size near the compressed oops limit. Either for someone who knows about the limit, but misses some nuance (they hear that 32GB is the maximum addressable space, and set Xmx32G, not realizing that the buffer required for the null page means that Xmx32G guarantees that you *won't* get compressed oops), or for someone who doesn't know about the limit and just chooses close to 32GB some other way, but loses out because the uncompressed oops use more space than the extra allotted (it's typical for people to recommend never choosing between 32 and say 36GB for this reason), or for someone that knows all this, and specifies Xmx31G because they don't know exactly what the maximum is on every server they run on, and lose out on up to 1GB of potential heap space.
What do people think of these two related ideas?
1. If the user sets *exactly* Xmx32G, we assume they intend or at least would benefit from compressed oops, so we reduce the chosen heap size to the maximum that compressed oops supports on their machine. We can limit the adjustment to some sanity value, like say 500MB, to avoid possible edge cases.
2. If the user sets anywhere in our chosen 'inefficient' range ((32GB - buffer) up to say 36GB), we reduce the chosen heap size to the maximum that compressed oops supports.
These would be accompanied by a warning message, and could be overridden with a new flag `-XX:+-AllowHeapAdjustmentForCompressedOops` or for 2 `-XX:MaxHeapAdjustmentForCompressedOops=4G` (naming suggestions welcome!).
Idea 1 is simply idea 2 with tighter bounds, but I suspect it covers the majority of useful cases while minimizing mistakes, so that's where I'd start. A dedicated way to say 'give me the max heap compressed oops supports' could also be valuable, but I don't think it offers much over 'magic' handling of 32G.
Oli
Amazon Development Centre (London) Ltd. Registered in England and Wales with registration number 04543232 with its registered office at 1 Principal Place, Worship Street, London EC2A 2FA, United Kingdom.
More information about the hotspot-dev
mailing list