Skip to content

Commit

Permalink
Backport 0e2fdc95ae47c11e6a1e47cdc6190268e29a9d9c
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealMDoerr committed May 31, 2024
1 parent 5cdff9f commit 8b7c4d5
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/hotspot/share/utilities/concurrentHashTable.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,23 +1197,30 @@ template <typename VALUE_SIZE_FUNC>
inline TableStatistics ConcurrentHashTable<CONFIG, F>::
statistics_calculate(Thread* thread, VALUE_SIZE_FUNC& vs_f)
{
constexpr size_t batch_size = 128;
NumberSeq summary;
size_t literal_bytes = 0;
InternalTable* table = get_table();
for (size_t bucket_it = 0; bucket_it < table->_size; bucket_it++) {
size_t num_batches = table->_size / batch_size;
for (size_t batch_start = 0; batch_start < _table->_size; batch_start += batch_size) {
// We batch the use of ScopedCS here as it has been found to be quite expensive to
// invoke it for every single bucket.
size_t batch_end = MIN2(batch_start + batch_size, _table->_size);
ScopedCS cs(thread, this);
size_t count = 0;
Bucket* bucket = table->get_bucket(bucket_it);
if (bucket->have_redirect() || bucket->is_locked()) {
continue;
}
Node* current_node = bucket->first();
while (current_node != NULL) {
++count;
literal_bytes += vs_f(current_node->value());
current_node = current_node->next();
for (size_t bucket_it = batch_start; bucket_it < batch_end; bucket_it++) {
size_t count = 0;
Bucket* bucket = table->get_bucket(bucket_it);
if (bucket->have_redirect() || bucket->is_locked()) {
continue;
}
Node* current_node = bucket->first();
while (current_node != nullptr) {
++count;
literal_bytes += vs_f(current_node->value());
current_node = current_node->next();
}
summary.add((double)count);
}
summary.add((double)count);
}

return TableStatistics(_stats_rate, summary, literal_bytes, sizeof(Bucket), sizeof(Node));
Expand Down

0 comments on commit 8b7c4d5

Please sign in to comment.