Skip to content

Commit

Permalink
8269571: NMT should print total malloc bytes and invocation count
Browse files Browse the repository at this point in the history
Reviewed-by: zgu, xliu
  • Loading branch information
tstuefe committed Jun 30, 2021
1 parent b969136 commit 3ad20fc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/hotspot/share/services/mallocTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ size_t MemoryCounter::peak_size() const {
}
#endif

// Total malloc invocation count
size_t MallocMemorySnapshot::total_count() const {
size_t amount = 0;
for (int index = 0; index < mt_number_of_types; index ++) {
amount += _malloc[index].malloc_count();
}
return amount;
}

// Total malloc'd memory amount
size_t MallocMemorySnapshot::total() const {
size_t amount = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/services/mallocTracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class MallocMemorySnapshot : public ResourceObj {
return &_tracking_header;
}

// Total malloc invocation count
size_t total_count() const;
// Total malloc'd memory amount
size_t total() const;
// Total malloc'd memory used by arenas
Expand Down
19 changes: 14 additions & 5 deletions src/hotspot/share/services/memReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ void MemReporterBase::print_virtual_memory_region(const char* type, address base

void MemSummaryReporter::report() {
outputStream* out = output();
size_t total_reserved_amount = _malloc_snapshot->total() +
_vm_snapshot->total_reserved();
size_t total_committed_amount = _malloc_snapshot->total() +
_vm_snapshot->total_committed();
const size_t total_malloced_bytes = _malloc_snapshot->total();
const size_t total_mmap_reserved_bytes = _vm_snapshot->total_reserved();
const size_t total_mmap_committed_bytes = _vm_snapshot->total_committed();

size_t total_reserved_amount = total_malloced_bytes + total_mmap_reserved_bytes;
size_t total_committed_amount = total_malloced_bytes + total_mmap_committed_bytes;

// Overall total
out->print_cr("\nNative Memory Tracking:\n");
Expand All @@ -113,7 +115,14 @@ void MemSummaryReporter::report() {

out->print("Total: ");
print_total(total_reserved_amount, total_committed_amount);
out->print("\n");
out->cr();
out->print_cr(" malloc: " SIZE_FORMAT "%s #" SIZE_FORMAT,
amount_in_current_scale(total_malloced_bytes), current_scale(),
_malloc_snapshot->total_count());
out->print(" mmap: ");
print_total(total_mmap_reserved_bytes, total_mmap_committed_bytes);
out->cr();
out->cr();

// Summary by memory type
for (int index = 0; index < mt_number_of_types; index ++) {
Expand Down

5 comments on commit 3ad20fc

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 3ad20fc Jun 30, 2021

Choose a reason for hiding this comment

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

@tstuefe could not automatically backport 3ad20fcd to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/hotspot/share/services/mallocTracker.cpp

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b tstuefe-backport-3ad20fcd
$ git fetch --no-tags https://git.openjdk.java.net/jdk 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76
$ git cherry-pick --no-commit 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76.

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 3ad20fc Oct 24, 2022

Choose a reason for hiding this comment

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

@tstuefe the backport was successfully created on the branch tstuefe-backport-3ad20fcd in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 3ad20fcd from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 30 Jun 2021 and was reviewed by Zhengyu Gu and Xin Liu.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-3ad20fcd:tstuefe-backport-3ad20fcd
$ git checkout tstuefe-backport-3ad20fcd
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-3ad20fcd

Please sign in to comment.