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

Disable biased-locking and deprecate all flags related to biased-locking

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 14
    • Fix Version/s: tbd
    • Component/s: hotspot

      Description

      Biased locking is an optimization technique used in the JVM to reduce the overhead of uncontended locking. It aims to avoid executing a compare-and-swap atomic operation when acquiring a Java monitor by assuming a monitor remains "owned" by a given thread until a different thread tries to acquire it. The initial lock of the monitor "biases" the monitor towards that thread, avoiding the need for atomic instructions in subsequent synchronized operations on the same object. When many threads perform many synchronized operations on objects used single-threaded, this has historically lead to significant performance improvements over regular locking techniques.

      However, biased locking introduces a lot of complex code to the synchronization subsystem and is invasive to other components in the VM as well. This complexity is a barrier to understanding various parts of the VM and an impediment to making significant design changes within the synchronization subsystem. To that end we would like to disable, deprecate and eventually remove support for biased-locking.

      The performance gains that were seen in the past are far less evident today. The cost of executing atomic instructions has decreased on modern processors since the introduction of biased locking into the VM. Furthermore many applications that benefited from biased locking are older legacy apps that were written using some of the early Java collections where synchronization was the default, i.e. Hashtable or Vector, before the non-synchronized HashMap and ArrayList were available and prior to the introduction of highly performant concurrent data structures in the core libraries in Java 5. From that time applications tend to either use the non-synchronized data structures for single-threaded use, or the concurrent data structures for multi-threaded use. As a general statement, applications that have the traditional thread pool queue and worker threads as their core architecture perform better with biased locking disabled, (which is what spec-jbb2015 has, and which spec-jvm98 and spec-jbb2005 do not have).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pchilanomate Patricio Chilano Mateo
                Reporter:
                pchilanomate Patricio Chilano Mateo
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: