< prev index next >
src/share/vm/memory/metaspace.cpp
Print this page
*** 23,32 ****
--- 23,33 ----
*/
#include "precompiled.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/gcLocker.hpp"
+ #include "logging/log.hpp"
#include "memory/allocation.hpp"
#include "memory/binaryTreeDictionary.hpp"
#include "memory/filemap.hpp"
#include "memory/freeList.hpp"
#include "memory/metachunk.hpp"
*** 809,820 ****
// BlockFreelist methods
BlockFreelist::BlockFreelist() : _dictionary(new BlockTreeDictionary()) {}
BlockFreelist::~BlockFreelist() {
! if (Verbose && TraceMetadataChunkAllocation) {
! dictionary()->print_free_lists(gclog_or_tty);
}
delete _dictionary;
}
void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
--- 810,823 ----
// BlockFreelist methods
BlockFreelist::BlockFreelist() : _dictionary(new BlockTreeDictionary()) {}
BlockFreelist::~BlockFreelist() {
! LogHandle(gc, metaspace, freelist) log;
! if (log.is_trace()) {
! ResourceMark rm;
! dictionary()->print_free_lists(log.trace_stream());
}
delete _dictionary;
}
void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
*** 890,904 ****
// Without this the is_available check will not work correctly.
assert(_virtual_space.committed_size() == _virtual_space.actual_committed_size(),
"The committed memory doesn't match the expanded memory.");
if (!is_available(chunk_word_size)) {
! if (TraceMetadataChunkAllocation) {
! gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available " SIZE_FORMAT " words ", chunk_word_size);
// Dump some information about the virtual space that is nearly full
! print_on(gclog_or_tty);
! }
return NULL;
}
// Take the space (bump top on the current virtual space).
inc_top(chunk_word_size);
--- 893,907 ----
// Without this the is_available check will not work correctly.
assert(_virtual_space.committed_size() == _virtual_space.actual_committed_size(),
"The committed memory doesn't match the expanded memory.");
if (!is_available(chunk_word_size)) {
! LogHandle(gc, metaspace, freelist) log;
! log.debug("VirtualSpaceNode::take_from_committed() not available " SIZE_FORMAT " words ", chunk_word_size);
// Dump some information about the virtual space that is nearly full
! ResourceMark rm;
! print_on(log.debug_stream());
return NULL;
}
// Take the space (bump top on the current virtual space).
inc_top(chunk_word_size);
*** 1229,1241 ****
inc_committed_words(new_entry->committed_words());
inc_virtual_space_count();
#ifdef ASSERT
new_entry->mangle();
#endif
! if (TraceMetavirtualspaceAllocation && Verbose) {
VirtualSpaceNode* vsl = current_virtual_space();
! vsl->print_on(gclog_or_tty);
}
}
bool VirtualSpaceList::expand_node_by(VirtualSpaceNode* node,
size_t min_words,
--- 1232,1246 ----
inc_committed_words(new_entry->committed_words());
inc_virtual_space_count();
#ifdef ASSERT
new_entry->mangle();
#endif
! LogHandle(gc, metaspace) log;
! if (log.is_develop()) {
VirtualSpaceNode* vsl = current_virtual_space();
! ResourceMark rm;
! vsl->print_on(log.develop_stream());
}
}
bool VirtualSpaceList::expand_node_by(VirtualSpaceNode* node,
size_t min_words,
*** 1328,1344 ****
return next;
}
void VirtualSpaceList::print_on(outputStream* st) const {
- if (TraceMetadataChunkAllocation && Verbose) {
VirtualSpaceListIterator iter(virtual_space_list());
while (iter.repeat()) {
VirtualSpaceNode* node = iter.get_next();
node->print_on(st);
}
- }
}
// MetaspaceGC methods
// VM_CollectForMetadataAllocation is the vm operation used to GC.
--- 1333,1347 ----
*** 1495,1515 ****
(size_t)MIN2(min_tmp, double(max_uintx));
// Don't shrink less than the initial generation size
minimum_desired_capacity = MAX2(minimum_desired_capacity,
MetaspaceSize);
! if (PrintGCDetails && Verbose) {
! gclog_or_tty->print_cr("\nMetaspaceGC::compute_new_size: ");
! gclog_or_tty->print_cr(" "
! " minimum_free_percentage: %6.2f"
! " maximum_used_percentage: %6.2f",
! minimum_free_percentage,
! maximum_used_percentage);
! gclog_or_tty->print_cr(" "
! " used_after_gc : %6.1fKB",
! used_after_gc / (double) K);
! }
size_t shrink_bytes = 0;
if (capacity_until_GC < minimum_desired_capacity) {
// If we have less capacity below the metaspace HWM, then
--- 1498,1511 ----
(size_t)MIN2(min_tmp, double(max_uintx));
// Don't shrink less than the initial generation size
minimum_desired_capacity = MAX2(minimum_desired_capacity,
MetaspaceSize);
! log_trace(gc, metaspace)("MetaspaceGC::compute_new_size: ");
! log_trace(gc, metaspace)(" minimum_free_percentage: %6.2f maximum_used_percentage: %6.2f",
! minimum_free_percentage, maximum_used_percentage);
! log_trace(gc, metaspace)(" used_after_gc : %6.1fKB", used_after_gc / (double) K);
size_t shrink_bytes = 0;
if (capacity_until_GC < minimum_desired_capacity) {
// If we have less capacity below the metaspace HWM, then
*** 1523,1544 ****
assert(succeeded, "Should always succesfully increment HWM when at safepoint");
Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
new_capacity_until_GC,
MetaspaceGCThresholdUpdater::ComputeNewSize);
! if (PrintGCDetails && Verbose) {
! gclog_or_tty->print_cr(" expanding:"
! " minimum_desired_capacity: %6.1fKB"
! " expand_bytes: %6.1fKB"
! " MinMetaspaceExpansion: %6.1fKB"
! " new metaspace HWM: %6.1fKB",
minimum_desired_capacity / (double) K,
expand_bytes / (double) K,
MinMetaspaceExpansion / (double) K,
new_capacity_until_GC / (double) K);
}
- }
return;
}
// No expansion, now see if we want to shrink
// We would never want to shrink more than this
--- 1519,1534 ----
assert(succeeded, "Should always succesfully increment HWM when at safepoint");
Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
new_capacity_until_GC,
MetaspaceGCThresholdUpdater::ComputeNewSize);
! log_trace(gc, metaspace)(" expanding: minimum_desired_capacity: %6.1fKB expand_bytes: %6.1fKB MinMetaspaceExpansion: %6.1fKB new metaspace HWM: %6.1fKB",
minimum_desired_capacity / (double) K,
expand_bytes / (double) K,
MinMetaspaceExpansion / (double) K,
new_capacity_until_GC / (double) K);
}
return;
}
// No expansion, now see if we want to shrink
// We would never want to shrink more than this
*** 1553,1574 ****
const double minimum_used_percentage = 1.0 - maximum_free_percentage;
const double max_tmp = used_after_gc / minimum_used_percentage;
size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
maximum_desired_capacity = MAX2(maximum_desired_capacity,
MetaspaceSize);
! if (PrintGCDetails && Verbose) {
! gclog_or_tty->print_cr(" "
! " maximum_free_percentage: %6.2f"
! " minimum_used_percentage: %6.2f",
! maximum_free_percentage,
! minimum_used_percentage);
! gclog_or_tty->print_cr(" "
! " minimum_desired_capacity: %6.1fKB"
! " maximum_desired_capacity: %6.1fKB",
! minimum_desired_capacity / (double) K,
! maximum_desired_capacity / (double) K);
! }
assert(minimum_desired_capacity <= maximum_desired_capacity,
"sanity check");
if (capacity_until_GC > maximum_desired_capacity) {
--- 1543,1556 ----
const double minimum_used_percentage = 1.0 - maximum_free_percentage;
const double max_tmp = used_after_gc / minimum_used_percentage;
size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
maximum_desired_capacity = MAX2(maximum_desired_capacity,
MetaspaceSize);
! log_trace(gc, metaspace)(" maximum_free_percentage: %6.2f minimum_used_percentage: %6.2f",
! maximum_free_percentage, minimum_used_percentage);
! log_trace(gc, metaspace)(" minimum_desired_capacity: %6.1fKB maximum_desired_capacity: %6.1fKB",
! minimum_desired_capacity / (double) K, maximum_desired_capacity / (double) K);
assert(minimum_desired_capacity <= maximum_desired_capacity,
"sanity check");
if (capacity_until_GC > maximum_desired_capacity) {
*** 1590,1616 ****
if (current_shrink_factor == 0) {
_shrink_factor = 10;
} else {
_shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100);
}
! if (PrintGCDetails && Verbose) {
! gclog_or_tty->print_cr(" "
! " shrinking:"
! " initSize: %.1fK"
! " maximum_desired_capacity: %.1fK",
! MetaspaceSize / (double) K,
! maximum_desired_capacity / (double) K);
! gclog_or_tty->print_cr(" "
! " shrink_bytes: %.1fK"
! " current_shrink_factor: %d"
! " new shrink factor: %d"
! " MinMetaspaceExpansion: %.1fK",
! shrink_bytes / (double) K,
! current_shrink_factor,
! _shrink_factor,
! MinMetaspaceExpansion / (double) K);
! }
}
}
// Don't shrink unless it's significant
if (shrink_bytes >= MinMetaspaceExpansion &&
--- 1572,1585 ----
if (current_shrink_factor == 0) {
_shrink_factor = 10;
} else {
_shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100);
}
! log_trace(gc, metaspace)(" shrinking: initSize: %.1fK maximum_desired_capacity: %.1fK",
! MetaspaceSize / (double) K, maximum_desired_capacity / (double) K);
! log_trace(gc, metaspace)(" shrink_bytes: %.1fK current_shrink_factor: %d new shrink factor: %d MinMetaspaceExpansion: %.1fK",
! shrink_bytes / (double) K, current_shrink_factor, _shrink_factor, MinMetaspaceExpansion / (double) K);
}
}
// Don't shrink unless it's significant
if (shrink_bytes >= MinMetaspaceExpansion &&
*** 1636,1649 ****
if (MetadataAllocationFailALot &&
Threads::is_vm_complete()) {
if (_allocation_fail_alot_count > 0) {
_allocation_fail_alot_count--;
} else {
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print_cr("Metadata allocation failing for "
! "MetadataAllocationFailALot");
! }
init_allocation_fail_alot_count();
return true;
}
}
return false;
--- 1605,1615 ----
if (MetadataAllocationFailALot &&
Threads::is_vm_complete()) {
if (_allocation_fail_alot_count > 0) {
_allocation_fail_alot_count--;
} else {
! log_trace(gc, metaspace, freelist)("Metadata allocation failing for MetadataAllocationFailALot");
init_allocation_fail_alot_count();
return true;
}
}
return false;
*** 1784,1814 ****
}
// Remove the chunk as the head of the list.
free_list->remove_chunk(chunk);
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print_cr("ChunkManager::free_chunks_get: free_list "
! PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT,
p2i(free_list), p2i(chunk), chunk->word_size());
- }
} else {
chunk = humongous_dictionary()->get_chunk(
word_size,
FreeBlockDictionary<Metachunk>::atLeast);
if (chunk == NULL) {
return NULL;
}
! if (TraceMetadataHumongousAllocation) {
! size_t waste = chunk->word_size() - word_size;
! gclog_or_tty->print_cr("Free list allocate humongous chunk size "
! SIZE_FORMAT " for requested size " SIZE_FORMAT
! " waste " SIZE_FORMAT,
! chunk->word_size(), word_size, waste);
! }
}
// Chunk is being removed from the chunks free list.
dec_free_chunks_total(chunk->word_size());
--- 1750,1772 ----
}
// Remove the chunk as the head of the list.
free_list->remove_chunk(chunk);
! log_trace(gc, metaspace, freelist)("ChunkManager::free_chunks_get: free_list " PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT,
p2i(free_list), p2i(chunk), chunk->word_size());
} else {
chunk = humongous_dictionary()->get_chunk(
word_size,
FreeBlockDictionary<Metachunk>::atLeast);
if (chunk == NULL) {
return NULL;
}
! log_debug(gc, metaspace, alloc)("Free list allocate humongous chunk size " SIZE_FORMAT " for requested size " SIZE_FORMAT " waste " SIZE_FORMAT,
! chunk->word_size(), word_size, chunk->word_size() - word_size);
}
// Chunk is being removed from the chunks free list.
dec_free_chunks_total(chunk->word_size());
*** 1837,1867 ****
}
assert((word_size <= chunk->word_size()) ||
list_index(chunk->word_size() == HumongousIndex),
"Non-humongous variable sized chunk");
! if (TraceMetadataChunkAllocation) {
size_t list_count;
if (list_index(word_size) < HumongousIndex) {
ChunkList* list = find_free_chunks_list(word_size);
list_count = list->count();
} else {
list_count = humongous_dictionary()->total_count();
}
! gclog_or_tty->print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk "
! PTR_FORMAT " size " SIZE_FORMAT " count " SIZE_FORMAT " ",
p2i(this), p2i(chunk), chunk->word_size(), list_count);
! locked_print_free_chunks(gclog_or_tty);
}
return chunk;
}
void ChunkManager::print_on(outputStream* out) const {
! if (PrintFLSStatistics != 0) {
! const_cast<ChunkManager *>(this)->humongous_dictionary()->report_statistics();
! }
}
// SpaceManager methods
void SpaceManager::get_initial_chunk_sizes(Metaspace::MetaspaceType type,
--- 1795,1824 ----
}
assert((word_size <= chunk->word_size()) ||
list_index(chunk->word_size() == HumongousIndex),
"Non-humongous variable sized chunk");
! LogHandle(gc, metaspace, freelist) log;
! if (log.is_debug()) {
size_t list_count;
if (list_index(word_size) < HumongousIndex) {
ChunkList* list = find_free_chunks_list(word_size);
list_count = list->count();
} else {
list_count = humongous_dictionary()->total_count();
}
! log.debug("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk " PTR_FORMAT " size " SIZE_FORMAT " count " SIZE_FORMAT " ",
p2i(this), p2i(chunk), chunk->word_size(), list_count);
! ResourceMark rm;
! locked_print_free_chunks(log.debug_stream());
}
return chunk;
}
void ChunkManager::print_on(outputStream* out) const {
! const_cast<ChunkManager *>(this)->humongous_dictionary()->report_statistics(out);
}
// SpaceManager methods
void SpaceManager::get_initial_chunk_sizes(Metaspace::MetaspaceType type,
*** 2037,2054 ****
assert(!SpaceManager::is_humongous(word_size) ||
chunk_word_size == if_humongous_sized_chunk,
"Size calculation is wrong, word_size " SIZE_FORMAT
" chunk_word_size " SIZE_FORMAT,
word_size, chunk_word_size);
! if (TraceMetadataHumongousAllocation &&
! SpaceManager::is_humongous(word_size)) {
! gclog_or_tty->print_cr("Metadata humongous allocation:");
! gclog_or_tty->print_cr(" word_size " PTR_FORMAT, word_size);
! gclog_or_tty->print_cr(" chunk_word_size " PTR_FORMAT,
! chunk_word_size);
! gclog_or_tty->print_cr(" chunk overhead " PTR_FORMAT,
! Metachunk::overhead());
}
return chunk_word_size;
}
void SpaceManager::track_metaspace_memory_usage() {
--- 1994,2009 ----
assert(!SpaceManager::is_humongous(word_size) ||
chunk_word_size == if_humongous_sized_chunk,
"Size calculation is wrong, word_size " SIZE_FORMAT
" chunk_word_size " SIZE_FORMAT,
word_size, chunk_word_size);
! LogHandle(gc, metaspace, alloc) log;
! if (log.is_debug() && SpaceManager::is_humongous(word_size)) {
! log.debug("Metadata humongous allocation:");
! log.debug(" word_size " PTR_FORMAT, word_size);
! log.debug(" chunk_word_size " PTR_FORMAT, chunk_word_size);
! log.debug(" chunk overhead " PTR_FORMAT, Metachunk::overhead());
}
return chunk_word_size;
}
void SpaceManager::track_metaspace_memory_usage() {
*** 2066,2085 ****
assert(current_chunk() == NULL ||
current_chunk()->allocate(word_size) == NULL,
"Don't need to expand");
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
! if (TraceMetadataChunkAllocation && Verbose) {
size_t words_left = 0;
size_t words_used = 0;
if (current_chunk() != NULL) {
words_left = current_chunk()->free_word_size();
words_used = current_chunk()->used_word_size();
}
! gclog_or_tty->print_cr("SpaceManager::grow_and_allocate for " SIZE_FORMAT
! " words " SIZE_FORMAT " words used " SIZE_FORMAT
! " words left",
word_size, words_used, words_left);
}
// Get another chunk
size_t grow_chunks_by_words = calc_chunk_size(word_size);
--- 2021,2038 ----
assert(current_chunk() == NULL ||
current_chunk()->allocate(word_size) == NULL,
"Don't need to expand");
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
! if (log_is_enabled(Trace, gc, metaspace, freelist)) {
size_t words_left = 0;
size_t words_used = 0;
if (current_chunk() != NULL) {
words_left = current_chunk()->free_word_size();
words_used = current_chunk()->used_word_size();
}
! log_trace(gc, metaspace, freelist)("SpaceManager::grow_and_allocate for " SIZE_FORMAT " words " SIZE_FORMAT " words used " SIZE_FORMAT " words left",
word_size, words_used, words_left);
}
// Get another chunk
size_t grow_chunks_by_words = calc_chunk_size(word_size);
*** 2167,2179 ****
Metadebug::init_allocation_fail_alot_count();
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
_chunks_in_use[i] = NULL;
}
_current_chunk = NULL;
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, p2i(this));
! }
}
void ChunkManager::return_chunks(ChunkIndex index, Metachunk* chunks) {
if (chunks == NULL) {
return;
--- 2120,2130 ----
Metadebug::init_allocation_fail_alot_count();
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
_chunks_in_use[i] = NULL;
}
_current_chunk = NULL;
! log_trace(gc, metaspace, freelist)("SpaceManager(): " PTR_FORMAT, p2i(this));
}
void ChunkManager::return_chunks(ChunkIndex index, Metachunk* chunks) {
if (chunks == NULL) {
return;
*** 2211,2223 ****
chunk_manager()->slow_locked_verify();
dec_total_from_size_metrics();
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, p2i(this));
! locked_print_chunks_in_use_on(gclog_or_tty);
}
// Do not mangle freed Metachunks. The chunk size inside Metachunks
// is during the freeing of a VirtualSpaceNodes.
--- 2162,2176 ----
chunk_manager()->slow_locked_verify();
dec_total_from_size_metrics();
! LogHandle(gc, metaspace, freelist) log;
! if (log.is_trace()) {
! log.trace("~SpaceManager(): " PTR_FORMAT, p2i(this));
! ResourceMark rm;
! locked_print_chunks_in_use_on(log.trace_stream());
}
// Do not mangle freed Metachunks. The chunk size inside Metachunks
// is during the freeing of a VirtualSpaceNodes.
*** 2231,2279 ****
// Follow each list of chunks-in-use and add them to the
// free lists. Each list is NULL terminated.
for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) {
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print_cr("returned " SIZE_FORMAT " %s chunks to freelist",
! sum_count_in_chunks_in_use(i),
! chunk_size_name(i));
! }
Metachunk* chunks = chunks_in_use(i);
chunk_manager()->return_chunks(i, chunks);
set_chunks_in_use(i, NULL);
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print_cr("updated freelist count " SSIZE_FORMAT " %s",
! chunk_manager()->free_chunks(i)->count(),
! chunk_size_name(i));
! }
assert(i != HumongousIndex, "Humongous chunks are handled explicitly later");
}
// The medium chunk case may be optimized by passing the head and
// tail of the medium chunk list to add_at_head(). The tail is often
// the current chunk but there are probably exceptions.
// Humongous chunks
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print_cr("returned " SIZE_FORMAT " %s humongous chunks to dictionary",
! sum_count_in_chunks_in_use(HumongousIndex),
! chunk_size_name(HumongousIndex));
! gclog_or_tty->print("Humongous chunk dictionary: ");
! }
// Humongous chunks are never the current chunk.
Metachunk* humongous_chunks = chunks_in_use(HumongousIndex);
while (humongous_chunks != NULL) {
#ifdef ASSERT
humongous_chunks->set_is_tagged_free(true);
#endif
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
! p2i(humongous_chunks),
! humongous_chunks->word_size());
! }
assert(humongous_chunks->word_size() == (size_t)
align_size_up(humongous_chunks->word_size(),
smallest_chunk_size()),
"Humongous chunk size is wrong: word size " SIZE_FORMAT
" granularity " SIZE_FORMAT,
--- 2184,2217 ----
// Follow each list of chunks-in-use and add them to the
// free lists. Each list is NULL terminated.
for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) {
! log.trace("returned " SIZE_FORMAT " %s chunks to freelist", sum_count_in_chunks_in_use(i), chunk_size_name(i));
Metachunk* chunks = chunks_in_use(i);
chunk_manager()->return_chunks(i, chunks);
set_chunks_in_use(i, NULL);
! log.trace("updated freelist count " SSIZE_FORMAT " %s", chunk_manager()->free_chunks(i)->count(), chunk_size_name(i));
assert(i != HumongousIndex, "Humongous chunks are handled explicitly later");
}
// The medium chunk case may be optimized by passing the head and
// tail of the medium chunk list to add_at_head(). The tail is often
// the current chunk but there are probably exceptions.
// Humongous chunks
! log.trace("returned " SIZE_FORMAT " %s humongous chunks to dictionary",
! sum_count_in_chunks_in_use(HumongousIndex), chunk_size_name(HumongousIndex));
! log.trace("Humongous chunk dictionary: ");
// Humongous chunks are never the current chunk.
Metachunk* humongous_chunks = chunks_in_use(HumongousIndex);
while (humongous_chunks != NULL) {
#ifdef ASSERT
humongous_chunks->set_is_tagged_free(true);
#endif
! log.trace(PTR_FORMAT " (" SIZE_FORMAT ") ", p2i(humongous_chunks), humongous_chunks->word_size());
assert(humongous_chunks->word_size() == (size_t)
align_size_up(humongous_chunks->word_size(),
smallest_chunk_size()),
"Humongous chunk size is wrong: word size " SIZE_FORMAT
" granularity " SIZE_FORMAT,
*** 2281,2296 ****
Metachunk* next_humongous_chunks = humongous_chunks->next();
humongous_chunks->container()->dec_container_count();
chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks);
humongous_chunks = next_humongous_chunks;
}
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->cr();
! gclog_or_tty->print_cr("updated dictionary count " SIZE_FORMAT " %s",
! chunk_manager()->humongous_dictionary()->total_count(),
! chunk_size_name(HumongousIndex));
! }
chunk_manager()->slow_locked_verify();
}
const char* SpaceManager::chunk_size_name(ChunkIndex index) const {
switch (index) {
--- 2219,2229 ----
Metachunk* next_humongous_chunks = humongous_chunks->next();
humongous_chunks->container()->dec_container_count();
chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks);
humongous_chunks = next_humongous_chunks;
}
! log.trace("updated dictionary count " SIZE_FORMAT " %s", chunk_manager()->humongous_dictionary()->total_count(), chunk_size_name(HumongousIndex));
chunk_manager()->slow_locked_verify();
}
const char* SpaceManager::chunk_size_name(ChunkIndex index) const {
switch (index) {
*** 2372,2386 ****
// Add to the running sum of capacity
inc_size_metrics(new_chunk->word_size());
assert(new_chunk->is_empty(), "Not ready for reuse");
! if (TraceMetadataChunkAllocation && Verbose) {
! gclog_or_tty->print("SpaceManager::add_chunk: " SIZE_FORMAT ") ",
! sum_count_in_chunks_in_use());
! new_chunk->print_on(gclog_or_tty);
! chunk_manager()->locked_print_free_chunks(gclog_or_tty);
}
}
void SpaceManager::retire_current_chunk() {
if (current_chunk() != NULL) {
--- 2305,2321 ----
// Add to the running sum of capacity
inc_size_metrics(new_chunk->word_size());
assert(new_chunk->is_empty(), "Not ready for reuse");
! LogHandle(gc, metaspace, freelist) log;
! if (log.is_trace()) {
! log.trace("SpaceManager::add_chunk: " SIZE_FORMAT ") ", sum_count_in_chunks_in_use());
! ResourceMark rm;
! outputStream* out = log.trace_stream();
! new_chunk->print_on(out);
! chunk_manager()->locked_print_free_chunks(out);
}
}
void SpaceManager::retire_current_chunk() {
if (current_chunk() != NULL) {
*** 2401,2414 ****
next = vs_list()->get_new_chunk(word_size,
grow_chunks_by_words,
medium_chunk_bunch());
}
! if (TraceMetadataHumongousAllocation && next != NULL &&
SpaceManager::is_humongous(next->word_size())) {
! gclog_or_tty->print_cr(" new humongous chunk word size "
! PTR_FORMAT, next->word_size());
}
return next;
}
--- 2336,2349 ----
next = vs_list()->get_new_chunk(word_size,
grow_chunks_by_words,
medium_chunk_bunch());
}
! LogHandle(gc, metaspace, alloc) log;
! if (log.is_debug() && next != NULL &&
SpaceManager::is_humongous(next->word_size())) {
! log.debug(" new humongous chunk word size " PTR_FORMAT, next->word_size());
}
return next;
}
*** 2569,2579 ****
capacity += curr->word_size();
waste += curr->free_word_size() + curr->overhead();;
}
}
! if (TraceMetadataChunkAllocation && Verbose) {
block_freelists()->print_on(out);
}
size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size();
// Free space isn't wasted.
--- 2504,2514 ----
capacity += curr->word_size();
waste += curr->free_word_size() + curr->overhead();;
}
}
! if (log_is_enabled(Trace, gc, metaspace, freelist)) {
block_freelists()->print_on(out);
}
size_t free = current_chunk() == NULL ? 0 : current_chunk()->free_word_size();
// Free space isn't wasted.
*** 2754,2784 ****
const ChunkManager* cm = Metaspace::get_chunk_manager(mdtype);
return cm->chunk_free_list_summary();
}
void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) {
! gclog_or_tty->print(", [Metaspace:");
! if (PrintGCDetails && Verbose) {
! gclog_or_tty->print(" " SIZE_FORMAT
! "->" SIZE_FORMAT
! "(" SIZE_FORMAT ")",
! prev_metadata_used,
! used_bytes(),
! reserved_bytes());
! } else {
! gclog_or_tty->print(" " SIZE_FORMAT "K"
! "->" SIZE_FORMAT "K"
! "(" SIZE_FORMAT "K)",
! prev_metadata_used/K,
! used_bytes()/K,
! reserved_bytes()/K);
! }
!
! gclog_or_tty->print("]");
}
- // This is printed when PrintGCDetails
void MetaspaceAux::print_on(outputStream* out) {
Metaspace::MetadataType nct = Metaspace::NonClassType;
out->print_cr(" Metaspace "
"used " SIZE_FORMAT "K, "
--- 2689,2702 ----
const ChunkManager* cm = Metaspace::get_chunk_manager(mdtype);
return cm->chunk_free_list_summary();
}
void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) {
! log_info(gc, metaspace)("Metaspace: " SIZE_FORMAT "K->" SIZE_FORMAT "K(" SIZE_FORMAT "K)",
! prev_metadata_used/K, used_bytes()/K, reserved_bytes()/K);
}
void MetaspaceAux::print_on(outputStream* out) {
Metaspace::MetadataType nct = Metaspace::NonClassType;
out->print_cr(" Metaspace "
"used " SIZE_FORMAT "K, "
*** 3131,3142 ****
set_narrow_klass_base_and_shift((address)metaspace_rs.base(),
UseSharedSpaces ? (address)cds_base : 0);
initialize_class_space(metaspace_rs);
! if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
! print_compressed_class_space(gclog_or_tty, requested_addr);
}
}
void Metaspace::print_compressed_class_space(outputStream* st, const char* requested_addr) {
st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d",
--- 3049,3062 ----
set_narrow_klass_base_and_shift((address)metaspace_rs.base(),
UseSharedSpaces ? (address)cds_base : 0);
initialize_class_space(metaspace_rs);
! LogHandle(gc, metaspace) log;
! if (log.is_develop()) {
! ResourceMark rm;
! print_compressed_class_space(log.develop_stream(), requested_addr);
}
}
void Metaspace::print_compressed_class_space(outputStream* st, const char* requested_addr) {
st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d",
*** 3284,3297 ****
// Set the compressed klass pointer base so that decoding of these pointers works
// properly when creating the shared archive.
assert(UseCompressedOops && UseCompressedClassPointers,
"UseCompressedOops and UseCompressedClassPointers must be set");
Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
! if (TraceMetavirtualspaceAllocation && Verbose) {
! gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT,
p2i(_space_list->current_virtual_space()->bottom()));
- }
Universe::set_narrow_klass_shift(0);
#endif // _LP64
#endif // INCLUDE_CDS
} else {
--- 3204,3215 ----
// Set the compressed klass pointer base so that decoding of these pointers works
// properly when creating the shared archive.
assert(UseCompressedOops && UseCompressedClassPointers,
"UseCompressedOops and UseCompressedClassPointers must be set");
Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
! log_develop(gc, metaspace)("Setting_narrow_klass_base to Address: " PTR_FORMAT,
p2i(_space_list->current_virtual_space()->bottom()));
Universe::set_narrow_klass_shift(0);
#endif // _LP64
#endif // INCLUDE_CDS
} else {
*** 3474,3487 ****
} while (!incremented && res == NULL);
if (incremented) {
tracer()->report_gc_threshold(before, after,
MetaspaceGCThresholdUpdater::ExpandAndAllocate);
! if (PrintGCDetails && Verbose) {
! gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
! " to " SIZE_FORMAT, before, after);
! }
}
return res;
}
--- 3392,3402 ----
} while (!incremented && res == NULL);
if (incremented) {
tracer()->report_gc_threshold(before, after,
MetaspaceGCThresholdUpdater::ExpandAndAllocate);
! log_trace(gc, metaspace)("Increase capacity to GC from " SIZE_FORMAT " to " SIZE_FORMAT, before, after);
}
return res;
}
*** 3640,3656 ****
void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) {
tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
// If result is still null, we are out of memory.
! if (Verbose && TraceMetadataChunkAllocation) {
! gclog_or_tty->print_cr("Metaspace allocation failed for size "
! SIZE_FORMAT, word_size);
if (loader_data->metaspace_or_null() != NULL) {
! loader_data->dump(gclog_or_tty);
}
! MetaspaceAux::dump(gclog_or_tty);
}
bool out_of_compressed_class_space = false;
if (is_class_space_allocation(mdtype)) {
Metaspace* metaspace = loader_data->metaspace_non_null();
--- 3555,3573 ----
void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) {
tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
// If result is still null, we are out of memory.
! LogHandle(gc, metaspace, freelist) log;
! if (log.is_trace()) {
! log.trace("Metaspace allocation failed for size " SIZE_FORMAT, word_size);
! ResourceMark rm;
! outputStream* out = log.trace_stream();
if (loader_data->metaspace_or_null() != NULL) {
! loader_data->dump(out);
}
! MetaspaceAux::dump(out);
}
bool out_of_compressed_class_space = false;
if (is_class_space_allocation(mdtype)) {
Metaspace* metaspace = loader_data->metaspace_non_null();
< prev index next >