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

Track the total usage of the code cache #4743

Merged
merged 1 commit into from
Jan 30, 2020

Conversation

a7ehuo
Copy link
Contributor

@a7ehuo a7ehuo commented Jan 21, 2020

To support -XX:+PrintCodeCache(eclipse-openj9/openj9#8184), the high water
mark of the code cache usage needs to be tracked.
The usage is tracked when increasing/decreasing the code cache repository
take place and also the reuse of the free blocks in the code cache.

The code cache usage reported in the javacore dump file will
reflect this change because increase/decreaseFreeSpaceInCodeCacheRepository
will also be called when the free blocks are reused/freed.

Added TR_PrintCodeCacheUsage to TR_CompilationOptions. It's set
when -XX:+PrintCodeCache is passed to the JVM or when it's set
as an environment variable.

Also added information on the config size, the total free size,
and the used size for each code cache in printOccupancyStats()
which is used by OpenJ9 to show the code cache usage
when TR_PrintCompMem is set.

Signed-off-by: Annabelle Huo Annabelle.Huo@ibm.com

@a7ehuo a7ehuo changed the title WIP: Track total code cache usage WIP: Track the total usage of the code cache Jan 22, 2020
Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution tracks code cache usage in 4 places:

  1. addFreeBlock2WithCallSite
  2. findFreeBlock
  3. increaseFreeSpaceInCodeCacheRepository
  4. decreaseFreeSpaceinCodeCacheRepository

The last two are used only if a code cache repository is used so it's not general enough (or 32 bit or for Power we don't use a repository)

compiler/runtime/OMRCodeCacheManager.hpp Outdated Show resolved Hide resolved
compiler/runtime/OMRCodeCache.cpp Outdated Show resolved Hide resolved
@mpirvu
Copy link
Contributor

mpirvu commented Jan 24, 2020

I am proposing one of two solutions:

  1. Everywhere we call increase/decreaseFreeSpaceInCodeCacheRepository add a call to increase/decreaseCurrTotalUsedInBytes
  2. Replace increase/decreaseFreeSpaceInCodeCacheRepository with increase/decreaseCurrTotalUsedInBytes and insert increase/decreaseFreeSpaceInCodeCacheRepository into increase/decreaseCurrTotalUsedInBytes

@a7ehuo
Copy link
Contributor Author

a7ehuo commented Jan 24, 2020

I'd prefer solution 2 to reduce the number of the calls that has to be inserted at the callers.

  1. Replace increase/decreaseFreeSpaceInCodeCacheRepository with increase/decreaseCurrTotalUsedInBytes and insert increase/decreaseFreeSpaceInCodeCacheRepository into increase/decreaseCurrTotalUsedInBytes

Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new solution will change the values we used to report in the javacore because we now track changes in the freedBlocks, but I guess it's more precise so it's better.

I have another suggestion: introduce the JIT option that will control the printing of the code cache information. Then, in openj9, you can turn on this option after parsing the corresponding VM option.

enum TR_CompilationOptions
   {
   ...
    TR_PrintCodeCacheUsage                           = 0x00000040 + 6,
   };
   {"enablePrintCodeCacheUsage", "O\tPrint code cache usage at shutdown", SET_OPTION_BIT(TR_PrintCodeCacheUsage), "F", NOT_IN_SUBSET},

and in openj9 you may want to do
self()->setOption(TR_PrintCodeCacheUsage) at the right point

@a7ehuo a7ehuo changed the title WIP: Track the total usage of the code cache Track the total usage of the code cache Jan 28, 2020
@a7ehuo a7ehuo marked this pull request as ready for review January 28, 2020 19:35
@a7ehuo
Copy link
Contributor Author

a7ehuo commented Jan 28, 2020

@Leonardo2718 Ready for review. Thanks!
@mpirvu FYI.

Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

To support `-XX:+PrintCodeCache`(eclipse-openj9/openj9#8184), the high water
mark of the code cache usage needs to be tracked.
The usage is tracked when increasing/decreasing the code cache repository
take place and also the reuse of the free blocks in the code cache.

The code cache usage reported in the javacore dump file will
reflect this change because increase/decreaseFreeSpaceInCodeCacheRepository
will also be called when the free blocks are reused/freed.

Added `TR_PrintCodeCacheUsage` to `TR_CompilationOptions`. It's set
when `-XX:+PrintCodeCache` is passed to the JVM or when it's set
as an environment variable.

Also added information on the config size, the total free size,
and the used size for each code cache in `printOccupancyStats()`
which is used by OpenJ9 to show the code cache usage
when `TR_PrintCompMem` is set.

Related to eclipse-openj9/openj9#8184

Signed-off-by: Annabelle Huo <Annabelle.Huo@ibm.com>
Copy link
Contributor

@Leonardo2718 Leonardo2718 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Leonardo2718
Copy link
Contributor

@genie-omr build all

@Leonardo2718 Leonardo2718 self-assigned this Jan 30, 2020
@a7ehuo
Copy link
Contributor Author

a7ehuo commented Jan 30, 2020

aix_ppc-64 build 1867 failed with the following error. It doesn't seem to be related to this change. The same failure seems to have started in PullRequest-aix_ppc-64 build 1860 (https://ci.eclipse.org/omr/job/PullRequest-aix_ppc-64/1860/console).

08:31:09  [ 21%] Building CXX object fvtest/compilertest/CMakeFiles/testcompiler.dir/__/__/compiler/codegen/ScratchRegisterManager.cpp.o
08:31:09  [ 21%] Linking CXX shared library libomrsig.a
08:31:09  ld: 0711-415 WARNING: Symbol omrsig_primary_signal is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol omrsig_handler is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol signal is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol omrsig_primary_sigaction is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol sigaction is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol sigset is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol sigignore is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol bsd_signal is already exported.
08:31:09  ld: 0711-415 WARNING: Symbol sysv_signal is already exported.
08:31:09  ld: 0711-317 ERROR: Undefined symbol: .pthread_sigmask
08:31:09  ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
08:31:09  make[2]: *** [omrsigcompat/CMakeFiles/omrsig.dir/build.make:90: omrsigcompat/libomrsig.a] Error 8
08:31:09  make[1]: *** [CMakeFiles/Makefile2:1656: omrsigcompat/CMakeFiles/omrsig.dir/all] Error 2
08:31:09  make[1]: *** Waiting for unfinished jobs....
08:31:09  Scanning dependencies of target omrutiltest
08:31:09  [ 21%] Building CXX object fvtest/compilertest/CMakeFiles/testcompiler.dir/__/__/compiler/codegen/StorageInfo.cpp.o
08:31:09  [ 21%] Building CXX object fvtest/utiltest/CMakeFiles/omrutiltest.dir/main.cpp.o
08:31:10  "/home/u0020236/workspace/PullRequest-aix_ppc-64/compiler/infra/OMRMonitor.hpp", line 50.46: 1540-1101 (W) A return value of type "int" is expected.

@Leonardo2718
Copy link
Contributor

aix_ppc-64 build 1867 failed with the following error. It doesn't seem to be related to this change [...]

That's correct. There's a discussion about that failure on https://eclipse-omr.slack.com/archives/CDEA8CP1Q.

If we can't find a solution for the problem soon, I'll just merge this PR as is.

@Leonardo2718
Copy link
Contributor

@genie-omr build aix

@Leonardo2718
Copy link
Contributor

All builds have now passed. Merging.

@Leonardo2718 Leonardo2718 merged commit 425d14b into eclipse-omr:master Jan 30, 2020
a7ehuo added a commit to a7ehuo/openj9 that referenced this pull request Feb 3, 2020
When `-XX:+PrintCodeCache` is passed to the JVM or
`TR_PrintCodeCacheUsage=1` is set, the following
code cache usage data will be shown when the JVM exits:

`CodeCache: size=262144Kb used=454Kb max_used=457Kb free=261690Kb`.

This implementation requires the code cache usage data
implemented in eclipse-omr/omr#4743.

If `TR_PrintCompMem` is set, the above code cache usage
information will be shown as well.

Fixes eclipse-openj9#8184

Signed-off-by: Annabelle Huo <Annabelle.Huo@ibm.com>
@a7ehuo a7ehuo deleted the printCodeCache branch February 24, 2020 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants