-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8281946: VM.native_memory should report size of shareable memory #11401
Changes from 1 commit
113692e
30ec28b
0eb837a
5e593cf
8e9e04c
2e8d26d
a473827
db019cb
aeb5802
bb4c341
6b7e4f3
aaac685
255da9e
d6aa9ac
b9ddcda
428e3fd
0120319
17874d9
7e2eca0
3c99737
217be8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
* | ||
*/ | ||
#include "precompiled.hpp" | ||
#include "cds/filemap.hpp" | ||
#include "memory/allocation.hpp" | ||
#include "memory/metaspace.hpp" | ||
#include "memory/metaspaceUtils.hpp" | ||
|
@@ -40,19 +39,29 @@ size_t MemReporterBase::committed_total(const MallocMemory* malloc, const Virtua | |
return malloc->malloc_size() + malloc->arena_size() + vm->committed(); | ||
} | ||
|
||
void MemReporterBase::print_total(size_t reserved, size_t committed) const { | ||
const char* scale = current_scale(); | ||
output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s", | ||
amount_in_current_scale(reserved), scale, | ||
amount_in_current_scale(committed), scale); | ||
// There can be upto two CDS archives which can contain readonly data. On Windows, pages are not | ||
// shareable so the RO region may not actually be read only | ||
size_t MemReporterBase::readonly_total(FileMapInfo* info) const { | ||
size_t total = 0; | ||
FileMapRegion* r; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be removed. |
||
if (info!= NULL) { | ||
FileMapRegion* r = info->region_at(MetaspaceShared::ro); | ||
if (r->read_only()) { | ||
total = r->used(); | ||
} | ||
} | ||
return total; | ||
} | ||
|
||
void MemReporterBase::print_total(size_t reserved, size_t committed, size_t read_only) const { | ||
void MemReporterBase::print_total(size_t reserved, size_t committed, size_t read_only = 0) const { | ||
const char* scale = current_scale(); | ||
output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s, readonly=" SIZE_FORMAT "%s", | ||
output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s", | ||
amount_in_current_scale(reserved), scale, | ||
amount_in_current_scale(committed), scale, | ||
amount_in_current_scale(read_only), scale); | ||
amount_in_current_scale(committed), scale); | ||
matias9927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (read_only > 0) { | ||
output()->print(", readonly=" SIZE_FORMAT "%s", | ||
amount_in_current_scale(read_only), scale); | ||
} | ||
} | ||
|
||
void MemReporterBase::print_malloc(size_t amount, size_t count, MEMFLAGS flag) const { | ||
|
@@ -114,13 +123,8 @@ void MemSummaryReporter::report() { | |
|
||
size_t total_reserved_amount = total_malloced_bytes + total_mmap_reserved_bytes; | ||
size_t total_committed_amount = total_malloced_bytes + total_mmap_committed_bytes; | ||
|
||
size_t read_only_bytes = 0; | ||
FileMapRegion* r = FileMapInfo::current_info()->region_at(MetaspaceShared::ro); | ||
// Region will be read-write on windows, otherwise this is a sanity check | ||
if (!MetaspaceShared::use_windows_memory_mapping()) | ||
assert(r->read_only(), "Region should be read only"); | ||
read_only_bytes = r->used(); | ||
size_t read_only_bytes = readonly_total(FileMapInfo::current_info()); // static archive | ||
read_only_bytes += readonly_total(FileMapInfo::dynamic_info()); // dynamic archive | ||
|
||
// Overall total | ||
out->print_cr("\nNative Memory Tracking:\n"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
#ifndef SHARE_SERVICES_MEMREPORTER_HPP | ||
#define SHARE_SERVICES_MEMREPORTER_HPP | ||
|
||
#include "cds/filemap.hpp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary in the header. Please move to the cpp file. |
||
#include "memory/metaspace.hpp" | ||
#include "oops/instanceKlass.hpp" | ||
#include "services/memBaseline.hpp" | ||
|
@@ -77,9 +78,9 @@ class MemReporterBase : public StackObj { | |
// Calculate total reserved and committed amount | ||
size_t reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const; | ||
size_t committed_total(const MallocMemory* malloc, const VirtualMemory* vm) const; | ||
size_t readonly_total(FileMapInfo* info) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary |
||
|
||
// Print summary total, malloc and virtual memory | ||
void print_total(size_t reserved, size_t committed) const; | ||
void print_total(size_t reserved, size_t committed, size_t read_only) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default parameter should be placed in the function declaration (here) and not in the function definition (in the cpp file). |
||
void print_malloc(size_t amount, size_t count, MEMFLAGS flag = mtNone) const; | ||
void print_virtual_memory(size_t reserved, size_t committed) const; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,9 @@ public static void main(String args[]) throws Exception { | |
|
||
// Match '- <mtType> (reserved=<reserved>KB, committed=<committed>KB) | ||
Pattern mtTypePattern = Pattern.compile("-\\s+(?<typename>[\\w\\s]+)\\(reserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB\\)"); | ||
// Match 'Total: reserved=<reserved>KB, committed=<committed>KB' | ||
// Match 'Total: reserved=<reserved>KB, committed=<committed>KB, readonly=<readonly>KB' | ||
Pattern totalMemoryPattern = Pattern.compile("Total\\:\\sreserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB,\\sreadonly=(?<readonly>\\d+)KB"); | ||
// Match '- <mtType> (reserved=<reserved>KB, committed=<committed>KB) | ||
// Match '- <mtType> (reserved=<reserved>KB, committed=<committed>KB, readonly<readonly>KB) | ||
Pattern mtSharedPattern = Pattern.compile("-\\s+(?<typename>[\\w\\s]+)\\(reserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB,\\sreadonly=(?<readonly>\\d+)KB\\)"); | ||
|
||
for (int i = 0; i < lines.length; i++) { | ||
|
@@ -80,6 +80,10 @@ public static void main(String args[]) throws Exception { | |
totalCommitted = Long.parseLong(totalMemoryMatcher.group("committed")); | ||
totalReserved = Long.parseLong(totalMemoryMatcher.group("reserved")); | ||
totalReadonly = Long.parseLong(totalMemoryMatcher.group("readonly")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. totalReadonly is nowhere used. Remove it? Or add a check for it? |
||
|
||
if (totalReadonly > totalCommitted) { | ||
throwTestException("Total readonly was more than committed"); | ||
} | ||
} else { | ||
throwTestException("Failed to match the expected groups in 'Total' memory part"); | ||
} | ||
|
@@ -97,9 +101,9 @@ public static void main(String args[]) throws Exception { | |
+ typeReserved + ") for mtType: " + typeMatcher.group("typename")); | ||
} | ||
// Make sure readonly is always less or equals | ||
if (typeShared > typeReserved) { | ||
throwTestException("Readonly (" + typeShared + ") was more than Reserved (" | ||
+ typeReserved + ") for mtType: " + typeMatcher.group("typename")); | ||
if (typeShared > typeCommitted) { | ||
throwTestException("Readonly (" + typeShared + ") was more than Committed (" | ||
+ typeCommitted + ") for mtType: " + typeMatcher.group("typename")); | ||
} | ||
|
||
// Add to total and compare them in the end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MemReporterBase::readonly_total is CDS stuff, can you please move it into CDS and make it a query function there? Lets not leak more CDS knowledge into NMT than necessary.
Typo: upto