Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8253646: ZGC: Avoid overhead of sorting ZStatIterableValues on bootstrap
Reviewed-by: pliden, eosterlund
  • Loading branch information
cl4es committed Sep 28, 2020
1 parent ec9bee6 commit 8e338f67b208e12c682fb3042660fd91c3244839
Showing with 30 additions and 13 deletions.
  1. +28 −13 src/hotspot/share/gc/z/zStat.cpp
  2. +2 −0 src/hotspot/share/gc/z/zStat.hpp
@@ -390,22 +390,35 @@ ZStatIterableValue<T>::ZStatIterableValue(const char* group,

template <typename T>
T* ZStatIterableValue<T>::insert() const {
T** current = &_first;
T* const next = _first;
_first = (T*)this;
return next;
}

while (*current != NULL) {
// First sort by group, then by name
const int group_cmp = strcmp((*current)->group(), group());
const int name_cmp = strcmp((*current)->name(), name());
if ((group_cmp > 0) || (group_cmp == 0 && name_cmp > 0)) {
break;
}
template <typename T>
void ZStatIterableValue<T>::sort() {
T* first_unsorted = _first;
_first = NULL;

while (first_unsorted != NULL) {
T* const value = first_unsorted;
first_unsorted = value->_next;
value->_next = NULL;

T** current = &_first;

while (*current != NULL) {
// First sort by group, then by name
const int group_cmp = strcmp((*current)->group(), value->group());
if ((group_cmp > 0) || (group_cmp == 0 && strcmp((*current)->name(), value->name()) > 0)) {
break;
}

current = &(*current)->_next;
current = &(*current)->_next;
}
value->_next = *current;
*current = value;
}

T* const next = *current;
*current = (T*)this;
return next;
}

//
@@ -882,6 +895,8 @@ void ZStat::run_service() {
ZStatSamplerHistory* const history = new ZStatSamplerHistory[ZStatSampler::count()];
LogTarget(Info, gc, stats) log;

ZStatSampler::sort();

// Main loop
while (_metronome.wait_for_tick()) {
sample_and_collect(history);
@@ -101,6 +101,8 @@ class ZStatIterableValue : public ZStatValue {
uint32_t size);

public:
static void sort();

static uint32_t count() {
return _count;
}

0 comments on commit 8e338f6

Please sign in to comment.