8253646: ZGC: Avoid overhead of sorting ZStatIterableValues on bootstrap
Reviewed-by: pliden, eosterlund
This commit is contained in:
parent
ec9bee6866
commit
8e338f67b2
@ -390,24 +390,37 @@ ZStatIterableValue<T>::ZStatIterableValue(const char* group,
|
||||
|
||||
template <typename T>
|
||||
T* ZStatIterableValue<T>::insert() const {
|
||||
T** current = &_first;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
current = &(*current)->_next;
|
||||
}
|
||||
|
||||
T* const next = *current;
|
||||
*current = (T*)this;
|
||||
T* const next = _first;
|
||||
_first = (T*)this;
|
||||
return next;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
value->_next = *current;
|
||||
*current = value;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Stat sampler
|
||||
//
|
||||
@ -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 @@ protected:
|
||||
uint32_t size);
|
||||
|
||||
public:
|
||||
static void sort();
|
||||
|
||||
static uint32_t count() {
|
||||
return _count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user