提交 9a4583ad 编写于 作者: Z zgu

8184991: NMT detail diff should take memory type into account

Summary: NMT detail allocation site comparison should compare sites with the same memory type
Reviewed-by: shade, coleenp
上级 b76445f8
/* /*
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -59,6 +59,15 @@ int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) { ...@@ -59,6 +59,15 @@ int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) {
return s1.call_stack()->compare(*s2.call_stack()); return s1.call_stack()->compare(*s2.call_stack());
} }
// Sort into allocation site addresses and memory type order for baseline comparison
int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) {
int res = compare_malloc_site(s1, s2);
if (res == 0) {
res = (int)(s1.flags() - s2.flags());
}
return res;
}
int compare_virtual_memory_site(const VirtualMemoryAllocationSite& s1, int compare_virtual_memory_site(const VirtualMemoryAllocationSite& s1,
const VirtualMemoryAllocationSite& s2) { const VirtualMemoryAllocationSite& s2) {
...@@ -225,6 +234,9 @@ MallocSiteIterator MemBaseline::malloc_sites(SortingOrder order) { ...@@ -225,6 +234,9 @@ MallocSiteIterator MemBaseline::malloc_sites(SortingOrder order) {
case by_site: case by_site:
malloc_sites_to_allocation_site_order(); malloc_sites_to_allocation_site_order();
break; break;
case by_site_and_type:
malloc_sites_to_allocation_site_and_type_order();
break;
case by_address: case by_address:
default: default:
ShouldNotReachHere(); ShouldNotReachHere();
...@@ -263,7 +275,7 @@ void MemBaseline::malloc_sites_to_size_order() { ...@@ -263,7 +275,7 @@ void MemBaseline::malloc_sites_to_size_order() {
} }
void MemBaseline::malloc_sites_to_allocation_site_order() { void MemBaseline::malloc_sites_to_allocation_site_order() {
if (_malloc_sites_order != by_site) { if (_malloc_sites_order != by_site && _malloc_sites_order != by_site_and_type) {
SortedLinkedList<MallocSite, compare_malloc_site> tmp; SortedLinkedList<MallocSite, compare_malloc_site> tmp;
// Add malloc sites to sorted linked list to sort into site (address) order // Add malloc sites to sorted linked list to sort into site (address) order
tmp.move(&_malloc_sites); tmp.move(&_malloc_sites);
...@@ -273,6 +285,17 @@ void MemBaseline::malloc_sites_to_allocation_site_order() { ...@@ -273,6 +285,17 @@ void MemBaseline::malloc_sites_to_allocation_site_order() {
} }
} }
void MemBaseline::malloc_sites_to_allocation_site_and_type_order() {
if (_malloc_sites_order != by_site_and_type) {
SortedLinkedList<MallocSite, compare_malloc_site_and_type> tmp;
// Add malloc sites to sorted linked list to sort into site (address) order
tmp.move(&_malloc_sites);
_malloc_sites.set_head(tmp.head());
tmp.set_head(NULL);
_malloc_sites_order = by_site_and_type;
}
}
void MemBaseline::virtual_memory_sites_to_size_order() { void MemBaseline::virtual_memory_sites_to_size_order() {
if (_virtual_memory_sites_order != by_size) { if (_virtual_memory_sites_order != by_size) {
SortedLinkedList<VirtualMemoryAllocationSite, compare_virtual_memory_size> tmp; SortedLinkedList<VirtualMemoryAllocationSite, compare_virtual_memory_size> tmp;
......
/* /*
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -55,9 +55,10 @@ class MemBaseline VALUE_OBJ_CLASS_SPEC { ...@@ -55,9 +55,10 @@ class MemBaseline VALUE_OBJ_CLASS_SPEC {
}; };
enum SortingOrder { enum SortingOrder {
by_address, // by memory address by_address, // by memory address
by_size, // by memory size by_size, // by memory size
by_site // by call site where the memory is allocated from by_site, // by call site where the memory is allocated from
by_site_and_type // by call site and memory type
}; };
private: private:
...@@ -188,6 +189,8 @@ class MemBaseline VALUE_OBJ_CLASS_SPEC { ...@@ -188,6 +189,8 @@ class MemBaseline VALUE_OBJ_CLASS_SPEC {
void malloc_sites_to_size_order(); void malloc_sites_to_size_order();
// Sort allocation sites in call site address order // Sort allocation sites in call site address order
void malloc_sites_to_allocation_site_order(); void malloc_sites_to_allocation_site_order();
// Sort allocation sites in call site address and memory type order
void malloc_sites_to_allocation_site_and_type_order();
// Sort allocation sites in reserved size order // Sort allocation sites in reserved size order
void virtual_memory_sites_to_size_order(); void virtual_memory_sites_to_size_order();
......
...@@ -312,11 +312,16 @@ void MemSummaryDiffReporter::report_diff() { ...@@ -312,11 +312,16 @@ void MemSummaryDiffReporter::report_diff() {
} }
void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count,
size_t early_amount, size_t early_count) const { size_t early_amount, size_t early_count, MEMFLAGS flags) const {
const char* scale = current_scale(); const char* scale = current_scale();
outputStream* out = output(); outputStream* out = output();
out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale);
// Report type only if it is valid
if (flags != mtNone) {
out->print(" type=%s", NMTUtil::flag_to_name(flags));
}
long amount_diff = diff_in_current_scale(current_amount, early_amount); long amount_diff = diff_in_current_scale(current_amount, early_amount);
if (amount_diff != 0) { if (amount_diff != 0) {
out->print(" %+ld%s", amount_diff, scale); out->print(" %+ld%s", amount_diff, scale);
...@@ -445,7 +450,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, const MallocMem ...@@ -445,7 +450,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, const MallocMem
diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) {
out->print("%28s(", " "); out->print("%28s(", " ");
print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(), print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(),
early_malloc_amount, early_malloc->malloc_count()); early_malloc_amount, early_malloc->malloc_count(), mtNone);
out->print_cr(")"); out->print_cr(")");
} }
...@@ -493,8 +498,8 @@ void MemDetailDiffReporter::report_diff() { ...@@ -493,8 +498,8 @@ void MemDetailDiffReporter::report_diff() {
} }
void MemDetailDiffReporter::diff_malloc_sites() const { void MemDetailDiffReporter::diff_malloc_sites() const {
MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site); MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type);
MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site); MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type);
const MallocSite* early_site = early_itr.next(); const MallocSite* early_site = early_itr.next();
const MallocSite* current_site = current_itr.next(); const MallocSite* current_site = current_itr.next();
...@@ -557,22 +562,23 @@ void MemDetailDiffReporter::diff_virtual_memory_sites() const { ...@@ -557,22 +562,23 @@ void MemDetailDiffReporter::diff_virtual_memory_sites() const {
void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const {
diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(),
0, 0); 0, 0, malloc_site->flags());
} }
void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const {
diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(),
malloc_site->count()); malloc_site->count(), malloc_site->flags());
} }
void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early,
const MallocSite* current) const { const MallocSite* current) const {
assert(early->flags() == current->flags(), "Must be the same memory type");
diff_malloc_site(current->call_stack(), current->size(), current->count(), diff_malloc_site(current->call_stack(), current->size(), current->count(),
early->size(), early->count()); early->size(), early->count(), early->flags());
} }
void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size,
size_t current_count, size_t early_size, size_t early_count) const { size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const {
outputStream* out = output(); outputStream* out = output();
assert(stack != NULL, "NULL stack"); assert(stack != NULL, "NULL stack");
...@@ -584,7 +590,7 @@ void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_ ...@@ -584,7 +590,7 @@ void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_
stack->print_on(out); stack->print_on(out);
out->print("%28s (", " "); out->print("%28s (", " ");
print_malloc_diff(current_size, current_count, print_malloc_diff(current_size, current_count,
early_size, early_count); early_size, early_count, flags);
out->print_cr(")\n"); out->print_cr(")\n");
} }
......
...@@ -174,7 +174,7 @@ class MemSummaryDiffReporter : public MemReporterBase { ...@@ -174,7 +174,7 @@ class MemSummaryDiffReporter : public MemReporterBase {
protected: protected:
void print_malloc_diff(size_t current_amount, size_t current_count, void print_malloc_diff(size_t current_amount, size_t current_count,
size_t early_amount, size_t early_count) const; size_t early_amount, size_t early_count, MEMFLAGS flags) const;
void print_virtual_memory_diff(size_t current_reserved, size_t current_committed, void print_virtual_memory_diff(size_t current_reserved, size_t current_committed,
size_t early_reserved, size_t early_committed) const; size_t early_reserved, size_t early_committed) const;
void print_arena_diff(size_t current_amount, size_t current_count, void print_arena_diff(size_t current_amount, size_t current_count,
...@@ -216,7 +216,7 @@ class MemDetailDiffReporter : public MemSummaryDiffReporter { ...@@ -216,7 +216,7 @@ class MemDetailDiffReporter : public MemSummaryDiffReporter {
const VirtualMemoryAllocationSite* current) const; const VirtualMemoryAllocationSite* current) const;
void diff_malloc_site(const NativeCallStack* stack, size_t current_size, void diff_malloc_site(const NativeCallStack* stack, size_t current_size,
size_t currrent_count, size_t early_size, size_t early_count) const; size_t currrent_count, size_t early_size, size_t early_count, MEMFLAGS flags) const;
void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved,
size_t current_committed, size_t early_reserved, size_t early_committed) const; size_t current_committed, size_t early_reserved, size_t early_committed) const;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册