JDK-8318016 : Per-compilation memory ceiling
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-10-12
  • Updated: 2024-05-08
  • Resolved: 2023-11-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 b22Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Using the new compiler memory statistic (JDK-8318016), implement per-compilation memory ceiling.

When reaching the ceiling, it should either crash with a hs-err file or stop the compilation. 

The latter is difficult to do at every allocation but can be approximated, for C2 at least, by hooking into the C2 node limit check.

Comments
Changeset: 0461d9a7 Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2023-11-01 08:12:39 +0000 URL: https://git.openjdk.org/jdk/commit/0461d9a7d67230736ce6370ff8146a60f3bd9cf3
01-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16220 Date: 2023-10-17 13:29:20 +0000
24-10-2023

That is a good idea and actually quite easy.
15-10-2023

May be delayed bail out: allocate on request in all cases but set a flag in compiler's arena and in places where we check Nodes limit `check_node_count()` check this flag too.
12-10-2023

I had such a solution on my list for a long time, complementing the node limit. But its tricky. The main issue is that you would have to fix every allocation site to check for allocation error. That is fiddly and probably would also cost performance. With C++ exceptions this would be easier.
12-10-2023

It would be nice if we can gracefully bail out only compilation which hits memory limit. I think users of Java will appreciate this. There is a concern that it may leave VM's memory in strange state which may cause issues while continue running. On other hand if we check only Arena usage by JIT compiler may be it is safe since we free used Arena space after finishing/exiting compilation.
12-10-2023