<div dir="ltr">Danke Jungs!<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 16, 2023 at 3:13 PM Matthias Baesken <<a href="mailto:mbaesken@openjdk.org">mbaesken@openjdk.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 15 Feb 2023 06:54:52 GMT, Thomas Stuefe <<a href="mailto:stuefe@openjdk.org" target="_blank">stuefe@openjdk.org</a>> wrote:<br>
<br>
>> Rework NMT `MallocLimit` to make it more useful for native OOM analysis. Also remove `MallocMaxTestWords`, which had been mostly redundant with NMT (for background, see JDK-8293292).<br>
>> <br>
>> <br>
>> ### Background<br>
>> <br>
>> Some months ago we had [JDK-8291919](<a href="https://bugs.openjdk.org/browse/JDK-8291919" rel="noreferrer" target="_blank">https://bugs.openjdk.org/browse/JDK-8291919</a>), a compiler regression that caused compiler arenas to grow boundlessly. Process was usually OOM-killed before we could take a look, so this was difficult to analyze.<br>
>> <br>
>> To improve analysis options, we added NMT *malloc limits* with [JDK-8291878](<a href="https://bugs.openjdk.org/browse/JDK-8291878" rel="noreferrer" target="_blank">https://bugs.openjdk.org/browse/JDK-8291878</a>). Malloc limits let us set one or multiple limits to malloc load. Surpassing a limit causes the VM to stop with a fatal error in the allocation function, giving us a hs-err file and a core right at the point that (probably) causes the leak. This makes error analysis a lot simpler, and is also valuable for regression-testing footprint usage.<br>
>> <br>
>> Some people wished for a way to not end with a fatal error but to mimic a native OOM (causing os::malloc to return NULL). This would allow us to test resilience in the face of native OOMs, among other things.<br>
>> <br>
>> ### Patch<br>
>> <br>
>> - Expands the `MallocLimit` option syntax, allowing for an "oom mode" that mimics an oom:<br>
>> <br>
>> <br>
>> <br>
>> Global form:<br>
>> -XX:MallocLimit=<size>[:<mode>]<br>
>> Category-specific form:<br>
>> -XX:MallocLimit=<category>:<size>[:<mode>][,<category>:<size>[:<mode>] ...]<br>
>> Examples:<br>
>> -XX:MallocLimit=3g<br>
>> -XX:MallocLimit=3g:oom<br>
>> -XX:MallocLimit=compiler:200m:oom<br>
>> <br>
>> <br>
>> - moves parsing of `-XX:MallocLimit` out of arguments.cpp into `mallocLimit.hpp/cpp`, and rewrites it.<br>
>> <br>
>> - changes when limits are checked. Before, the limits were checked *after* the allocation that caused the threshold overflow. Now we check beforehand.<br>
>> <br>
>> - removes `MallocMaxTestWords`, replacing its uses with `MallocLimit`<br>
>> <br>
>> - adds new gtests and new jtreg tests<br>
>> <br>
>> - removes a bunch of jtreg tests which are now better served by the new gtests.<br>
>> <br>
>> - gives us more precise error messages upon reaching a limit. For example:<br>
>> <br>
>> before:<br>
>> <br>
>> #  fatal error: MallocLimit: category "Compiler" reached limit (size: 20997680, limit: 20971520)<br>
>> <br>
>> <br>
>> now:<br>
>> <br>
>> #  fatal error: MallocLimit: reached category "Compiler" limit (triggering allocation size: 1920B, allocated so far: 20505K, limit: 20480K)<br>
><br>
> Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 11 commits:<br>
> <br>
>  - Merge branch 'openjdk:master' into JDK-8293313-NMT-fake-oom<br>
>  - nullptr<br>
>  - merge and fix conflicts<br>
>  - Merge; fix conflicts<br>
>  - Feedback Gerard<br>
>  - Revert strchrnul<br>
>  - Copyrights<br>
>  - Feedback Johan<br>
>  - Merge<br>
>  - Merge branch 'master' into JDK-8293313-NMT-fake-oom<br>
>  - ... and 1 more: <a href="https://git.openjdk.org/jdk/compare/98a392c4...2d02a5bd" rel="noreferrer" target="_blank">https://git.openjdk.org/jdk/compare/98a392c4...2d02a5bd</a><br>
<br>
LGTM.<br>
<br>
Will there be a release note documenting the changed/removed XX-flags ? Maybe there should be one .<br>
<br>
-------------<br>
<br>
Marked as reviewed by mbaesken (Reviewer).<br>
<br>
PR: <a href="https://git.openjdk.org/jdk/pull/11371" rel="noreferrer" target="_blank">https://git.openjdk.org/jdk/pull/11371</a><br>
</blockquote></div>