[lworld] (LIFE = Legacy Idiom For Equality) causes performance regressions

XMLWordPrintable

    • generic
    • generic

      LIFE (Legacy Idiom For Equality) is an optimization that makes a reference equality check before the "equals" method invocation to speed up the equality check.
      Like it's implemented in the Objects.equals method:
       public static boolean equals(Object a, Object b) {
              return (a == b) || (a != null && a.equals(b));
       }

      In Valhalla, such equality optimization causes performance regression. Reference check on value classes (and/or migrated classes) is expensive and really unnecessary.

      1. SPECjbb2005 has -7% regressions.
      The source: equality check for j.l.Integer inside j.u.HashMap.

      2. A simple microbenchmark like:
          @Benchmark
          public OffsetDateTime odt_now() {
              return OffsetDateTime.now();
          }
      has -30% performance regression.
      The source: ConcurrentMap<Integer, ZoneOffsetTransition[]> lastRulesCache

            Assignee:
            Roger Riggs
            Reporter:
            Sergey Kuksenko
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: