Skip to content

8330677: Add Per-Compilation memory usage to JFR#18864

Closed
tstuefe wants to merge 3 commits intoopenjdk:masterfrom
tstuefe:JDK-8330677-Add-Per-Compilation-memory-usage-to-JFR
Closed

8330677: Add Per-Compilation memory usage to JFR#18864
tstuefe wants to merge 3 commits intoopenjdk:masterfrom
tstuefe:JDK-8330677-Add-Per-Compilation-memory-usage-to-JFR

Conversation

@tstuefe
Copy link
Member

@tstuefe tstuefe commented Apr 19, 2024

We have the (opt-in, disabled by default) compiler memory statistics introduced with JDK-8317683.

Since temporary memory usage by compilers can significantly affect process footprint, it would make sense to expose at least the total peak usage per compilation via JFR.


This patch adds "Arena Usage" to CompilationEvent. We now see in JMC how costly a compilation had been. (The cost can get very high, as we have seen just recently again with JDK-8327247 ).

jmc-memstat


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8330677: Add Per-Compilation memory usage to JFR (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18864/head:pull/18864
$ git checkout pull/18864

Update a local copy of the PR:
$ git checkout pull/18864
$ git pull https://git.openjdk.org/jdk.git pull/18864/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18864

View PR using the GUI difftool:
$ git pr show -t 18864

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18864.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 19, 2024

👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 19, 2024

@tstuefe This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8330677: Add Per-Compilation memory usage to JFR

Reviewed-by: kvn, mbaesken

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 22 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8330677: Add Per-Compilation memory usage to JFR 8330677: Add Per-Compilation memory usage to JFR Apr 19, 2024
@openjdk
Copy link

openjdk bot commented Apr 19, 2024

@tstuefe The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Apr 19, 2024
@tstuefe tstuefe marked this pull request as ready for review April 21, 2024 06:48
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 21, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 21, 2024

Webrevs

@tstuefe
Copy link
Member Author

tstuefe commented Apr 22, 2024

/label hotspot-compiler

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Apr 22, 2024
@openjdk
Copy link

openjdk bot commented Apr 22, 2024

@tstuefe
The hotspot-compiler label was successfully added.

@tstuefe
Copy link
Member Author

tstuefe commented Apr 22, 2024

/label remove hotspot

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Apr 22, 2024
@openjdk
Copy link

openjdk bot commented Apr 22, 2024

@tstuefe
The hotspot label was successfully removed.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 23, 2024
@MBaesken
Copy link
Member

Please also check COPYRIGHT years, e.g. compileTask.cpp .
Could you also check if there is an easy way to enhance some existing test for the JFR Compilation event. always good to have at least some basic testing .

@MBaesken
Copy link
Member

We have the (opt-in, disabled by default)

Might be helpful to add to the Description part of https://bugs.openjdk.org/browse/JDK-8317683 another sentence that describes how to enable the feature.

@tstuefe
Copy link
Member Author

tstuefe commented Apr 26, 2024

Thanks @MBaesken . Please check again to see if I addressed all your issues.

@MBaesken
Copy link
Member

MBaesken commented Apr 26, 2024

Regarding src/hotspot/share/jfr/metadata/metadata.xml , could you label it 'Arena Peak Usage' or something like this ? I would like to have it more clear that it is the peak usage.
Did you check my nullptr check related question ?
Otherwise looks okay to me.
It is a bit unfortunate that by default , we have now an 'empty' added field in the JFR Compilation event. But it is what it is; any chances that the compiler mem statistics would be enabled by default in the future, or is this considered too costly ?

@tstuefe
Copy link
Member Author

tstuefe commented Apr 26, 2024

Regarding src/hotspot/share/jfr/metadata/metadata.xml , could you label it 'Arena Peak Usage' or something like this ? I would like to have it more clear that it is the peak usage.

I already find "Arena Usage" to be too long, to be honest. Longer column labels make the JMC table less readable (ideally, one would have a "label," short and descriptive, and a "description," one being the column label, the other, e.g., a tooltip).

And "peak" is really the only option that makes sense here. If you ask someone what they think "usage" means, they will assume its the largest footprint accumulated during compilation over the time span of the compilation, aka peak.

Did you check my nullptr check related question ?

I read through the comments twice and did not find a nullptr related question. Which question?

Otherwise looks okay to me. It is a bit unfortunate that by default , we have now an 'empty' added field in the JFR Compilation event. But it is what it is; any chances that the compiler mem statistics would be enabled by default in the future, or is this considered too costly ?

One synchronization per compilation. So, not that costly, no. It will be enabled by default in debug builds with #18969 since it is implied in memlimit.

@MBaesken
Copy link
Member

MBaesken commented Apr 29, 2024

I read through the comments twice and did not find a nullptr related question. Which question?

See compilationMemoryStatistic.cpp .

At some places we check the result for nullptr e.g.

jdk/src/hotspot/share/compiler/compilationMemoryStatistic.cpp

Line 79 in b3bcc49

 const CompileTask* const task = th->task(); 

@tstuefe
Copy link
Member Author

tstuefe commented Apr 29, 2024

I read through the comments twice and did not find a nullptr related question. Which question?

See compilationMemoryStatistic.cpp .

At some places we check the result for nullptr e.g.

jdk/src/hotspot/share/compiler/compilationMemoryStatistic.cpp

Line 79 in b3bcc49

 const CompileTask* const task = th->task(); 

Yes, it is inconsistent. Allmost all code here (notably anything triggered from start- or end-compilation) are called from the compiler so we run on a compiler thread and in the scope of a ciEnv. So most of the existing nullptr checks are probably not needed.

We may want to make this consistent with subsequent RFEs.

@MBaesken
Copy link
Member

We may want to make this consistent with subsequent RFEs.

I agree, this can be a follow up.

CompilerThread* const th = Thread::current()->as_Compiler_thread();
ArenaStatCounter* const arena_stat = th->arena_stat();
const CompilerType ct = th->task()->compiler()->type();
CompileTask* const task = th->task();
Copy link
Member

Choose a reason for hiding this comment

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

At some places we check the result for nullptr e.g.

const CompileTask* const task = th->task();

Is that over cautious or should it better be done ?

const char* _failure_reason;
// Specifies if _failure_reason is on the C heap.
bool _failure_reason_on_C_heap;
size_t _arena_bytes; // peak size of temporary memory during compilation (e.g. node arenas)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a good reason not to name it _peak_arena_bytes when it is always the peak as stated ?

<Field type="boolean" name="isOsr" label="On Stack Replacement" />
<Field type="ulong" contentType="bytes" name="codeSize" label="Compiled Code Size" />
<Field type="ulong" contentType="bytes" name="inlinedBytes" label="Inlined Code Size" />
<Field type="ulong" contentType="bytes" name="arenaBytes" label="Arena Usage" />
Copy link
Member

Choose a reason for hiding this comment

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

Maybe say Peak arena usage, if this is the case as stated above ?
And some info that it is optional / must be enabled to see this data would probably help too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Again, there is no space for this. "label" gets used as column header. No space to add a descriptive text.

@tstuefe
Copy link
Member Author

tstuefe commented Apr 29, 2024

Thanks @MBaesken . For some reason your remarks only got posted now, but I think we covered all points already.

/integrate

@openjdk
Copy link

openjdk bot commented Apr 29, 2024

Going to push as commit 151ef5d.
Since your change was applied there have been 22 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 29, 2024
@openjdk openjdk bot closed this Apr 29, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 29, 2024
@openjdk
Copy link

openjdk bot commented Apr 29, 2024

@tstuefe Pushed as commit 151ef5d.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants