52 #include "utilities/concurrentHashTable.inline.hpp" |
52 #include "utilities/concurrentHashTable.inline.hpp" |
53 #include "utilities/concurrentHashTableTasks.inline.hpp" |
53 #include "utilities/concurrentHashTableTasks.inline.hpp" |
54 #include "utilities/macros.hpp" |
54 #include "utilities/macros.hpp" |
55 |
55 |
56 // We prefer short chains of avg 2 |
56 // We prefer short chains of avg 2 |
57 #define PREF_AVG_LIST_LEN 2 |
57 const double PREF_AVG_LIST_LEN = 2.0; |
58 // 2^24 is max size |
58 // 2^24 is max size |
59 #define END_SIZE 24 |
59 const size_t END_SIZE = 24; |
60 // If a chain gets to 32 something might be wrong |
60 // If a chain gets to 32 something might be wrong |
61 #define REHASH_LEN 32 |
61 const size_t REHASH_LEN = 32; |
62 // If we have as many dead items as 50% of the number of bucket |
62 // If we have as many dead items as 50% of the number of bucket |
63 #define CLEAN_DEAD_HIGH_WATER_MARK 0.5 |
63 const double CLEAN_DEAD_HIGH_WATER_MARK = 0.5; |
64 |
64 |
65 #if INCLUDE_CDS_JAVA_HEAP |
65 #if INCLUDE_CDS_JAVA_HEAP |
66 inline oop read_string_from_compact_hashtable(address base_address, u4 offset) { |
66 inline oop read_string_from_compact_hashtable(address base_address, u4 offset) { |
67 assert(sizeof(narrowOop) == sizeof(offset), "must be"); |
67 assert(sizeof(narrowOop) == sizeof(offset), "must be"); |
68 narrowOop v = (narrowOop)offset; |
68 narrowOop v = (narrowOop)offset; |
214 |
214 |
215 size_t StringTable::item_added() { |
215 size_t StringTable::item_added() { |
216 return Atomic::add((size_t)1, &(the_table()->_items_count)); |
216 return Atomic::add((size_t)1, &(the_table()->_items_count)); |
217 } |
217 } |
218 |
218 |
219 size_t StringTable::add_items_count_to_clean(size_t ndead) { |
219 size_t StringTable::add_items_to_clean(size_t ndead) { |
220 size_t total = Atomic::add((size_t)ndead, &(the_table()->_uncleaned_items_count)); |
220 size_t total = Atomic::add((size_t)ndead, &(the_table()->_uncleaned_items_count)); |
221 log_trace(stringtable)( |
221 log_trace(stringtable)( |
222 "Uncleaned items:" SIZE_FORMAT " added: " SIZE_FORMAT " total:" SIZE_FORMAT, |
222 "Uncleaned items:" SIZE_FORMAT " added: " SIZE_FORMAT " total:" SIZE_FORMAT, |
223 the_table()->_uncleaned_items_count, ndead, total); |
223 the_table()->_uncleaned_items_count, ndead, total); |
224 return total; |
224 return total; |
226 |
226 |
227 void StringTable::item_removed() { |
227 void StringTable::item_removed() { |
228 Atomic::add((size_t)-1, &(the_table()->_items_count)); |
228 Atomic::add((size_t)-1, &(the_table()->_items_count)); |
229 } |
229 } |
230 |
230 |
231 double StringTable::get_load_factor() { |
231 double StringTable::get_load_factor() const { |
232 return (double)_items_count/_current_size; |
232 return (double)_items_count/_current_size; |
233 } |
233 } |
234 |
234 |
235 double StringTable::get_dead_factor() { |
235 double StringTable::get_dead_factor() const { |
236 return (double)_uncleaned_items_count/_current_size; |
236 return (double)_uncleaned_items_count/_current_size; |
237 } |
237 } |
238 |
238 |
239 size_t StringTable::table_size() { |
239 size_t StringTable::table_size() { |
240 return ((size_t)1) << _local_table->get_size_log2(Thread::current()); |
240 return ((size_t)1) << _local_table->get_size_log2(Thread::current()); |
430 StringTableIsAliveCounter stiac(cl); |
430 StringTableIsAliveCounter stiac(cl); |
431 |
431 |
432 _par_state_string->weak_oops_do(&stiac, &dnc); |
432 _par_state_string->weak_oops_do(&stiac, &dnc); |
433 |
433 |
434 // Accumulate the dead strings. |
434 // Accumulate the dead strings. |
435 the_table()->add_items_count_to_clean(stiac._count); |
435 the_table()->add_items_to_clean(stiac._count); |
436 |
436 |
437 *processed = stiac._count_total; |
437 *processed = stiac._count_total; |
438 *removed = stiac._count; |
438 *removed = stiac._count; |
439 } |
439 } |
440 |
440 |