Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8253646

ZGC: Avoid overhead of sorting ZStatIterableValues on bootstrap

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 16
    • 16
    • hotspot
    • gc
    • b18

      Startup profiles show some small, unnecessary overhead in static initializers creation various ZStat objects, and part of that is due comparing names in ZStatIterableValue::insert even when the insertion order is defined by group name.

      gcc doesn't see through strcmp and optimize this so that the strcmp on name is only done when needed, so we need to move the comparison on name into the test:

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

      This avoids a tiny amount of work (~30k insns) on bootstrap.

      Additionally, the sorting can be deferred completely to when starting the ZStat service, which removes the remaining overhead when not running the stat service.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: