Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Loom] Excessive JIT memory usage in Skynet test #16424

Closed
fengxue-IS opened this issue Dec 6, 2022 · 6 comments · Fixed by #16644
Closed

[Loom] Excessive JIT memory usage in Skynet test #16424

fengxue-IS opened this issue Dec 6, 2022 · 6 comments · Fixed by #16644
Assignees
Labels
comp:jit jdk19 project:loom Used to track Project Loom related work
Milestone

Comments

@fengxue-IS
Copy link
Contributor

fengxue-IS commented Dec 6, 2022

When triaging #15939, I noticed that there seem to be excessive allocation from JIT

I was using -Xmx512M option, test resulted in using:
VM:
1.4GB total memory
~512MB heap memory
~500MB thread memory
~300MB class memory
JIT
~15GB total memory
~250MB code cache

Maybe similar to #16148

To reproduce:

Testcase: https://github.com/ibmruntimes/openj9-openjdk-jdk19/blob/openj9/test/jdk/java/lang/Thread/virtual/stress/Skynet.java
compile with javac --enable-preview -source 19 Skynet.java
run with java --enable-preview --Xnocompressedrefs -Xmx512M Skynet

FYI @0xdaryl @tajila

@fengxue-IS fengxue-IS added this to the Java 19 milestone Dec 6, 2022
@tajila tajila added the jdk19 label Dec 6, 2022
@fengxue-IS
Copy link
Contributor Author

This may also be one of the reason for the significant perf regression against RI (5-6x) with JIT enabled. When testing with -Xint OpenJ9 has 10-20% better perf than RI

@fengxue-IS fengxue-IS added the project:loom Used to track Project Loom related work label Dec 9, 2022
@0xdaryl
Copy link
Contributor

0xdaryl commented Jan 17, 2023

At the moment, Skynet consistently crashes with the latest JDK 19 on x86-64 Linux with either the "Invalid JIT Return Address" problem or a crash in the VM or GC. It is probably worth waiting for those issues to be resolved before spending time investigating this.

@0xdaryl
Copy link
Contributor

0xdaryl commented Jan 26, 2023

I am able to run this on a 96-thread Cascade Lake now. Studying the verbose log memory statistics of a few runs doesn't show anything close to 15GB memory consumption (some profiles at higher opt are in the 250-300MB range).

What technique did you use to measure the memory consumption? In the meantime I'll look at more process-based statistics as well as what the javacore tells me late in a run.

@fengxue-IS
Copy link
Contributor Author

I was monitor the memory usage via top command on my fyre machine, I also generated a java core to confirm the memory usage.

@0xdaryl
Copy link
Contributor

0xdaryl commented Jan 27, 2023

There does appear to be an excessive allocation problem. 99.2% of all JVM allocations running Skynet are coming from jitGetExceptionTableFromPC, specifically from here:

artifactSearchCache = j9mem_allocate_memory(JIT_ARTIFACT_SEARCH_CACHE_SIZE * sizeof (TR_jit_artifact_search_cache), OMRMEM_CATEGORY_JIT);

Given the rate of growth I doubt this memory is ever freed. Still figuring out why and what can be done about it.

@0xdaryl
Copy link
Contributor

0xdaryl commented Jan 27, 2023

vmThread->jitArtifactSearchCache is always NULL, leading us to allocate a 4k chunk each time this code is called that is never freed.

0xdaryl added a commit to 0xdaryl/openj9 that referenced this issue Feb 2, 2023
Temporary `J9VMThread`s are created to present `J9VMContinuation` thread data
to the stackwalker.  Explicitly disable the JIT artifact cache on the temporary
thread otherwise the stack walker will allocate a new 4K buffer for each
temporary `J9VMThread` whose memory must be managed.

These threads exist to perform a single stack walk and the benefits of managing
and using a JIT artifact cache appear to be limited.

Fixes: eclipse-openj9#16424

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jit jdk19 project:loom Used to track Project Loom related work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants