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

ZGC: Avoid overhead of sorting ZStatIterableValues on bootstrap

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: 16
    • Fix Version/s: 16
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
      gc
    • Resolved In Build:
      b18

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: