Class LockMetrics

java.lang.Object
org.ek9lang.core.LockMetrics

public final class LockMetrics extends Object
How much the compiler's one program lock (SharedThreadContext) is used and waited for - the measure of what serialises the front end. Process-wide counters: acquisitions, time spent waiting to acquire, and time the outermost holder held it.

Off unless asked for (-Dek9.lockMetrics=true, or setEnabled(boolean)). SYMBOL_DEFINITION takes the lock millions of times on a large workspace, and timing every acquisition would distort the run it measures. When off, the cost is one volatile read per acquisition.

Read as before/after differences around a phase or stage (snapshot()); never reset, so concurrent readers cannot disturb each other.

  • Method Details

    • isEnabled

      public static boolean isEnabled()
      True when acquisitions are being counted and timed.
    • setEnabled

      public static void setEnabled(boolean enable)
      Turn the counting on or off - for tests and tools; the system property sets the starting value.
    • snapshot

      public static LockMetrics.Snapshot snapshot()
      The counters now.
    • recordAcquisition

      static void recordAcquisition(long waitNanos)
    • recordHold

      static void recordHold(long holdNanos)