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

Prevent compilation requests to be re-issued when code cache is exhausted #20448

Open
mpirvu opened this issue Oct 30, 2024 · 1 comment · May be fixed by #20511
Open

Prevent compilation requests to be re-issued when code cache is exhausted #20448

mpirvu opened this issue Oct 30, 2024 · 1 comment · May be fixed by #20511
Assignees
Labels

Comments

@mpirvu
Copy link
Contributor

mpirvu commented Oct 30, 2024

When the code cache becomes full, the JIT uses
getCompilationInfo()->getPersistentInfo()->setDisableFurtherCompilation(true)
to prevent future compilation requests from being queued. The rejection happens in

compileOnSeparateThread()
   {
...
   if ((getNumCompThreadsActive() == 0
#if defined(J9VM_OPT_CRIU_SUPPORT)
        || getCRRuntime()->shouldSuspendThreadsForCheckpoint()
#endif
        || getPersistentInfo()->getDisableFurtherCompilation())
       && !details.isJitDumpMethod())
      {
      bool shouldReturn = true;

      // Fail the compilation, unless this is on the queue (maybe even in progress)
      if (!requestExistsInCompilationQueue(details, fe))
         {
         startPC = compilationEnd(vmThread, details, _jitConfig, 0, oldStartPC);
         }
...
   }

Typically, once a method fails compilation, the JIT calls compilationEnd() which will call jitMethodFailedTranslation(vmThread, method), which writes J9_JIT_NEVER_TRANSLATE into j9method->extra so that the interpreter doesn't continue to send this method for compilation. The code looks like this:

   else if (!oldStartPC)
      {
      // Tell the VM that a non-compiled method failed translation
      //
      if (vmThread && entry && !entry->isOutOfProcessCompReq())
         jitMethodFailedTranslation(vmThread, method);

Note that calling jitMethodFailedTranslation(vmThread, method); is gated by a test on entry. When a compilation is rejected early due to the getPersistentInfo()->getDisableFurtherCompilation() test, the entry does not exist because the compilation request has not yet been added to the compilation queue. Thus, j9method->extra is not set to J9_JIT_NEVER_TRANSLATE and the interpreter will send the method over and over again to the JIT compiler.

This issue proposes to eliminate the test on entry in compilationEnd() , provided it is safe to do so.

@mpirvu mpirvu self-assigned this Oct 30, 2024
Copy link

Issue Number: 20448
Status: Open
Recommended Components: comp:vm, comp:gc, comp:test
Recommended Assignees: babsingh, thallium, tajila

mpirvu added a commit to mpirvu/openj9 that referenced this issue Nov 5, 2024
For large applications, the code caches can become full,
preventing further JIT compilation. Compilation requests
issued by the invocation counting mechanism of the interpreter
will be rejected early by the JIT, before having the chance
of being queued for compilation. Ideally, once a method has
been rejected once, it will not be sent again for compilation.
Currently this is not happening due to the circumstances
described in eclipse-openj9#20448

This commit will prevent an interpreted method to be sent
repeatedly for JIT compilation if compilation is disabled
(because of code/data caches becoming full or because of a user
specified command line option).

Fixes: eclipse-openj9#20448

Signed-off-by: Marius Pirvu <mpirvu@ca.ibm.com>
mpirvu added a commit to mpirvu/openj9 that referenced this issue Nov 5, 2024
For large applications, the code caches can become full,
preventing further JIT compilation. Compilation requests
issued by the invocation counting mechanism of the interpreter
will be rejected early by the JIT, before having the chance
of being queued for compilation. Ideally, once a method has
been rejected once, it will not be sent again for compilation.
Currently this is not happening due to the circumstances
described in eclipse-openj9#20448

This commit will prevent an interpreted method to be sent
repeatedly for JIT compilation if compilation is disabled
(because of code/data caches becoming full or because of a user
specified command line option).

Fixes: eclipse-openj9#20448

Signed-off-by: Marius Pirvu <mpirvu@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant