mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 01:24:33 +02:00
8306738: Select num workers for safepoint ParallelCleanupTask
Reviewed-by: shade, coleenp, tschatzl
This commit is contained in:
parent
a05560d993
commit
672bade522
7 changed files with 116 additions and 12 deletions
|
@ -116,6 +116,8 @@ static size_t _current_size = 0;
|
|||
static volatile size_t _items_count = 0;
|
||||
|
||||
volatile bool _alt_hash = false;
|
||||
|
||||
static bool _rehashed = false;
|
||||
static uint64_t _alt_hash_seed = 0;
|
||||
|
||||
uintx hash_string(const jchar* s, int len, bool useAlt) {
|
||||
|
@ -529,20 +531,46 @@ bool StringTable::do_rehash() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool StringTable::should_grow() {
|
||||
return get_load_factor() > PREF_AVG_LIST_LEN && !_local_table->is_max_size_reached();
|
||||
}
|
||||
|
||||
bool StringTable::rehash_table_expects_safepoint_rehashing() {
|
||||
// No rehashing required
|
||||
if (!needs_rehashing()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Grow instead of rehash
|
||||
if (should_grow()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Already rehashed
|
||||
if (_rehashed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Resizing in progress
|
||||
if (!_local_table->is_safepoint_safe()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void StringTable::rehash_table() {
|
||||
static bool rehashed = false;
|
||||
log_debug(stringtable)("Table imbalanced, rehashing called.");
|
||||
|
||||
// Grow instead of rehash.
|
||||
if (get_load_factor() > PREF_AVG_LIST_LEN &&
|
||||
!_local_table->is_max_size_reached()) {
|
||||
if (should_grow()) {
|
||||
log_debug(stringtable)("Choosing growing over rehashing.");
|
||||
trigger_concurrent_work();
|
||||
_needs_rehashing = false;
|
||||
return;
|
||||
}
|
||||
// Already rehashed.
|
||||
if (rehashed) {
|
||||
if (_rehashed) {
|
||||
log_warning(stringtable)("Rehashing already done, still long lists.");
|
||||
trigger_concurrent_work();
|
||||
_needs_rehashing = false;
|
||||
|
@ -552,7 +580,7 @@ void StringTable::rehash_table() {
|
|||
_alt_hash_seed = AltHashing::compute_seed();
|
||||
{
|
||||
if (do_rehash()) {
|
||||
rehashed = true;
|
||||
_rehashed = true;
|
||||
} else {
|
||||
log_info(stringtable)("Resizes in progress rehashing skipped.");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue