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

UseMembar should be set true and deprecate the flag

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 10
    • hotspot
    • None
    • behavioral
    • minimal
    • Hide
      Generally, except the new warning, the VM should behave the same.

      There is a possibility of performance loss in some very specific cases.
      Show
      Generally, except the new warning, the VM should behave the same. There is a possibility of performance loss in some very specific cases.
    • add/remove/modify command line option
    • Implementation

      Summary

      Change default of -XX:+UseMembar from false to true and deprecate the flag.

      Problem

      Hotspot currently has two mechanisms for forcing memory synchronization across threads. The default mechanism uses mprotect to force a pseudo-memory barrier, while the alternate (chosen by -XX:+UseMembar) uses a direct memory fence operation.

      Using mprotect for IPI has several problems:

      • It's not guaranteed to work on future hardware/OS:es (we could start using membarrier() with the MEMBARRIER_CMD_SHARED_EXPEDITED to be future proof (coming in 4.14))
      • It doesn't work on arm/arm64 (again MEMBARRIER_CMD_SHARED_EXPEDITED would solve this)
      • Eventbased tracing must read thread states often (causes performance issues)
      • The complexity in the code is costly
      • The thread serialization is unstable on certain workloads/platforms/OS:es (last noticed this week on win x86)
      • Fences are becoming cheaper
      • Thread-local handshakes are assumed to increase the reading of thread state
      • Scalability
      • JNI performance - false sharing

      We want to move away from the mprotect mechanism.

      Solution

      Set UseMembar to default to true and deprecate the flag. In the future we will obsolete the flag and only provide the membar mechanism.

      Note that some applications can show performance regression. This is especially true for applications with few threads which do many short native calls.

      Specification

      Java HotSpot(TM) 64-Bit Server VM warning: Option UseMembar was deprecated in version 10.0 and will likely be removed in a future release.

      diff -r 6b8d7ed4fd9d src/cpu/ppc/vm/globals_ppc.hpp
      --- a/src/cpu/ppc/vm/globals_ppc.hpp    Mon Sep 25 17:22:56 2017 +0200
      +++ b/src/cpu/ppc/vm/globals_ppc.hpp    Tue Sep 26 12:21:17 2017 +0200
      @@ -72,1 +72,1 @@
      -define_pd_global(bool, UseMembar,             false);
      +define_pd_global(bool, UseMembar,             true);
      diff -r 6b8d7ed4fd9d src/cpu/s390/vm/globals_s390.hpp
      --- a/src/cpu/s390/vm/globals_s390.hpp  Mon Sep 25 17:22:56 2017 +0200
      +++ b/src/cpu/s390/vm/globals_s390.hpp  Tue Sep 26 12:21:17 2017 +0200
      @@ -74,1 +74,1 @@
      -define_pd_global(bool, UseMembar,            false);
      +define_pd_global(bool, UseMembar,            true);
      diff -r 6b8d7ed4fd9d src/cpu/sparc/vm/globals_sparc.hpp
      --- a/src/cpu/sparc/vm/globals_sparc.hpp    Mon Sep 25 17:22:56 2017 +0200
      +++ b/src/cpu/sparc/vm/globals_sparc.hpp    Tue Sep 26 12:21:17 2017 +0200
      @@ -77,1 +77,1 @@
      -define_pd_global(bool, UseMembar,            false);
      +define_pd_global(bool, UseMembar,            true);
      diff -r 6b8d7ed4fd9d src/cpu/x86/vm/globals_x86.hpp
      --- a/src/cpu/x86/vm/globals_x86.hpp    Mon Sep 25 17:22:56 2017 +0200
      +++ b/src/cpu/x86/vm/globals_x86.hpp    Tue Sep 26 12:21:17 2017 +0200
      @@ -87,1 +86,0 @@
      -#ifdef _ALLBSD_SOURCE
      @@ -89,3 +87,0 @@
      -#else
      -define_pd_global(bool, UseMembar,            false);
      -#endif
      diff -r 6b8d7ed4fd9d src/share/vm/runtime/arguments.cpp
      --- a/src/share/vm/runtime/arguments.cpp    Mon Sep 25 17:22:56 2017 +0200
      +++ b/src/share/vm/runtime/arguments.cpp    Tue Sep 26 12:21:17 2017 +0200
      @@ -384,0 +385,1 @@
      +  { "UseMembar",                    JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },

            rehn Robbin Ehn
            rehn Robbin Ehn
            David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: