Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2879

Replace Map.computeIfAbsent()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 5.4.8
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      1. Measure the cost of lambda creation on a Map.computeIfAbsent()
      2. Compare this (in JMH) to code like this:

      val=map.get(key);
      if(val == null)
         map.computeIfAbsent()
      

      If the key/value pair has been added to the map, the simple invocation of computeIfAbsent() creates a new lambda on every invocation even if get() returns a non-null value. The lambda is not invoked, but it will still be created.

      If this proves to be costly, replace all occurrences in JGroups with the above pattern.

      There might be other cases where lambdas are created; check them, too.

      Note that this is only important for code on the critical path.

              rhn-engineering-bban Bela Ban
              rhn-engineering-bban Bela Ban
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: