src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp
Print this page
rev 6141 : [mq]: review_fixes
@@ -67,18 +67,18 @@
return _length;
}
};
//
-// Cache of deduplication table enties. This cache provides fast allocation and
-// reuse of table entries to lower the preasure on the underlaying allocator.
+// Cache of deduplication table entries. This cache provides fast allocation and
+// reuse of table entries to lower the pressure on the underlying allocator.
// But more importantly, it provides fast/deferred freeing of table entries. This
// is important because freeing of table entries is done during stop-the-world
-// phases and it is not uncommon for large number of String to be freed at once.
+// phases and it is not uncommon for large number of entries to be freed at once.
// Tables entries that are freed during these phases are placed onto a freelist in
// the cache. The deduplication thread, which executes in a concurrent phase, will
-// later reuse or free the underlaying memory for these entries.
+// later reuse or free the underlying memory for these entries.
//
// The cache allows for single-threaded allocations and multi-threaded frees.
// Allocations are synchronized by StringDedupTable_lock as part of a table
// modification.
//
@@ -99,10 +99,13 @@
G1StringDedupEntry* alloc();
// Insert a table entry into the cache freelist.
void free(G1StringDedupEntry* entry, uint worker_id);
+ // Returns current number of entries in the cache.
+ size_t size();
+
// If the cache has grown above the given max size, trim it down
// and deallocate the memory occupied by trimmed of entries.
void trim(size_t max_size);
};
@@ -131,10 +134,18 @@
entry->set_obj(NULL);
entry->set_hash(0);
_lists[worker_id].add(entry);
}
+size_t G1StringDedupEntryCache::size() {
+ size_t size = 0;
+ for (size_t i = 0; i < _nlists; i++) {
+ size += _lists[i].length();
+ }
+ return size;
+}
+
void G1StringDedupEntryCache::trim(size_t max_size) {
size_t cache_size = 0;
for (size_t i = 0; i < _nlists; i++) {
G1StringDedupEntryFreeList* list = &_lists[i];
cache_size += list->length();
@@ -543,16 +554,16 @@
void G1StringDedupTable::print_statistics(outputStream* st) {
st->print_cr(
" [Table]\n"
" [Memory Usage: "G1_STRDEDUP_BYTES_FORMAT_NS"]\n"
" [Size: "SIZE_FORMAT", Min: "SIZE_FORMAT", Max: "SIZE_FORMAT"]\n"
- " [Entries: "UINTX_FORMAT", Load: "G1_STRDEDUP_PERCENT_FORMAT_NS", Added: "UINTX_FORMAT", Removed: "UINTX_FORMAT"]\n"
+ " [Entries: "UINTX_FORMAT", Load: "G1_STRDEDUP_PERCENT_FORMAT_NS", Cached: " UINTX_FORMAT ", Added: "UINTX_FORMAT", Removed: "UINTX_FORMAT"]\n"
" [Resize Count: "UINTX_FORMAT", Shrink Threshold: "UINTX_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT_NS"), Grow Threshold: "UINTX_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT_NS")]\n"
" [Rehash Count: "UINTX_FORMAT", Rehash Threshold: "UINTX_FORMAT", Hash Seed: 0x%x]\n"
" [Age Threshold: "UINTX_FORMAT"]",
- G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + _table->_entries * sizeof(G1StringDedupEntry)),
+ G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)),
_table->_size, _min_size, _max_size,
- _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entries_added, _entries_removed,
+ _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entry_cache->size(), _entries_added, _entries_removed,
_resize_count, _table->_shrink_threshold, _shrink_load_factor * 100.0, _table->_grow_threshold, _grow_load_factor * 100.0,
_rehash_count, _rehash_threshold, _table->_hash_seed,
StringDeduplicationAgeThreshold);
}