Skip to content

Commit

Permalink
8290870: NMT: Increase MallocSiteTable size and allocate it only when…
Browse files Browse the repository at this point in the history
… needed

Reviewed-by: zgu, dholmes
  • Loading branch information
tstuefe committed Jul 25, 2022
1 parent 0599a05 commit 852e71d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/hotspot/share/services/mallocSiteTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "services/mallocSiteTable.hpp"

// Malloc site hashtable buckets
MallocSiteHashtableEntry* MallocSiteTable::_table[MallocSiteTable::table_size];
MallocSiteHashtableEntry** MallocSiteTable::_table = NULL;
const NativeCallStack* MallocSiteTable::_hash_entry_allocation_stack = NULL;
const MallocSiteHashtableEntry* MallocSiteTable::_hash_entry_allocation_site = NULL;

Expand All @@ -43,6 +43,12 @@ const MallocSiteHashtableEntry* MallocSiteTable::_hash_entry_allocation_site = N
*/
bool MallocSiteTable::initialize() {

ALLOW_C_FUNCTION(::calloc,
_table = (MallocSiteHashtableEntry**)::calloc(table_size, sizeof(MallocSiteHashtableEntry*));)
if (_table == nullptr) {
return false;
}

// Fake the call stack for hashtable entry allocation
assert(NMT_TrackingStackDepth > 1, "At least one tracking stack");

Expand Down
11 changes: 2 additions & 9 deletions src/hotspot/share/services/mallocSiteTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,7 @@ class MallocSiteTable : AllStatic {
// be tuned if malloc activities changed significantly.
// The statistics data can be obtained via Jcmd
// jcmd <pid> VM.native_memory statistics.

// Currently, (number of buckets / number of entries) ratio is
// about 1 / 6
enum {
table_base_size = 128, // The base size is calculated from statistics to give
// table ratio around 1:6
table_size = (table_base_size * NMT_TrackingStackDepth - 1)
};
static const int table_size = 4099;

// Table cannot be wider than a 16bit bucket idx can hold
#define MAX_MALLOCSITE_TABLE_SIZE (USHRT_MAX - 1)
Expand Down Expand Up @@ -196,7 +189,7 @@ class MallocSiteTable : AllStatic {
private:
// The callsite hashtable. It has to be a static table,
// since malloc call can come from C runtime linker.
static MallocSiteHashtableEntry* _table[table_size];
static MallocSiteHashtableEntry** _table;
static const NativeCallStack* _hash_entry_allocation_stack;
static const MallocSiteHashtableEntry* _hash_entry_allocation_site;
};
Expand Down

1 comment on commit 852e71d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.