Uploaded image for project: 'JBoss Cache'
  1. JBoss Cache
  2. JBCACHE-1543

Remove contention due to PessimisticUnversionedNode.getLock()

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.2.1.CR1
    • Component/s: Locking
    • Labels:
      None

      Description

      PessimisticUnversionedNode.getLock() shows up as a middling contention hotspot in profiling tests. The method always calls initLock(), which is a synchronized method. So any lock attempts will first have to briefly get the monitor for the node before they can move on to acquiring the lock. This adds contention in the case of for higher level structural nodes in a tree (e.g. Fqn.ROOT).

      Solution is to make the PessimisticNodeLock.lock field volatile and then only call initLock() if it is null; aka double-checked locking. Making the field volatile ensures that the IdentityLock object is fully constructed before it is visible to other threads reading PessimisticUnversionedNode.lock, which is the requirement for making double-checked locking correct.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                brian.stansberry Brian Stansberry
                Reporter:
                brian.stansberry Brian Stansberry
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: