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) on PROCESS). 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.

  • Field Details

    • PROCESS

      public static final LockMetrics PROCESS
      THE lock metrics of this process. The program lock's use is one fact for the run, so this is the one documented process-wide holder (Steve, 2026-10-28, no static methods: the counters stay process-wide, the behaviour is held as an instance): every SharedThreadContext records into it and every reader snapshots it.
  • Method Details

    • isEnabled

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

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

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

      void recordAcquisition(long nanosWaited)
    • recordHold

      void recordHold(long nanosHeld)