Record Class ResourceSnapshot

java.lang.Object
java.lang.Record
org.ek9lang.compiler.common.ResourceSnapshot

public record ResourceSnapshot(long wallNanos, long cpuNanos, long allocatedBytes, long gcCount, long gcMillis, LockMetrics.Snapshot lock) extends Record
THE measurement of a window of compilation - a phase or a stage of one - used by the verbose PHASE_METRICS and *_STAGE lines so every window is measured the same way. Take one at the start, one at the end, and describe the difference.
  • cpu / busyCores - process CPU time, and that divided by wall time: how many cores the window kept busy. A window that barely speeds up with more threads is either stalling on many cores (busyCores high) or not running on many cores at all (busyCores near 1) - wall time alone cannot tell those apart, and they need opposite fixes.
  • alloc - bytes allocated by all threads: the pressure behind garbage collection.
  • gc - collections and their accumulated time.
  • lock - acquisitions of, waits for and holds of the program lock, only when LockMetrics is enabled (-Dek9.lockMetrics=true).

Any figure the JVM cannot supply is reported as -1 rather than guessed.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceSnapshot(long wallNanos, long cpuNanos, long allocatedBytes, long gcCount, long gcMillis, LockMetrics.Snapshot lock)
    Creates an instance of a ResourceSnapshot record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the allocatedBytes record component.
    double
    Megabytes allocated from this snapshot to later; -1 when unavailable.
    double
    How many cores were busy on average from this snapshot to later; -1 when CPU time is unavailable.
    long
    Returns the value of the cpuNanos record component.
    The resource use from this snapshot to later, as appended to a verbose timing line: cpu 123.4 ms busyCores 3.21 alloc 456.7 MB gc 3 in 12 ms and, when lock metrics are on, lock 1234 acquisitions wait 5.6 ms held 78.9 ms.
    final boolean
    Indicates whether some other object is "equal to" this one.
    long
    Returns the value of the gcCount record component.
    long
    Returns the value of the gcMillis record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the lock record component.
    double
    Wall time from this snapshot to later, in milliseconds.
    now()
    The counters now.
    final String
    Returns a string representation of this record class.
    long
    Returns the value of the wallNanos record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ResourceSnapshot

      public ResourceSnapshot(long wallNanos, long cpuNanos, long allocatedBytes, long gcCount, long gcMillis, LockMetrics.Snapshot lock)
      Creates an instance of a ResourceSnapshot record class.
      Parameters:
      wallNanos - the value for the wallNanos record component
      cpuNanos - the value for the cpuNanos record component
      allocatedBytes - the value for the allocatedBytes record component
      gcCount - the value for the gcCount record component
      gcMillis - the value for the gcMillis record component
      lock - the value for the lock record component
  • Method Details

    • now

      public static ResourceSnapshot now()
      The counters now.
    • millisTo

      public double millisTo(ResourceSnapshot later)
      Wall time from this snapshot to later, in milliseconds.
    • busyCoresTo

      public double busyCoresTo(ResourceSnapshot later)
      How many cores were busy on average from this snapshot to later; -1 when CPU time is unavailable.
    • allocatedMegabytesTo

      public double allocatedMegabytesTo(ResourceSnapshot later)
      Megabytes allocated from this snapshot to later; -1 when unavailable.
    • describeTo

      public String describeTo(ResourceSnapshot later)
      The resource use from this snapshot to later, as appended to a verbose timing line: cpu 123.4 ms busyCores 3.21 alloc 456.7 MB gc 3 in 12 ms and, when lock metrics are on, lock 1234 acquisitions wait 5.6 ms held 78.9 ms.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • wallNanos

      public long wallNanos()
      Returns the value of the wallNanos record component.
      Returns:
      the value of the wallNanos record component
    • cpuNanos

      public long cpuNanos()
      Returns the value of the cpuNanos record component.
      Returns:
      the value of the cpuNanos record component
    • allocatedBytes

      public long allocatedBytes()
      Returns the value of the allocatedBytes record component.
      Returns:
      the value of the allocatedBytes record component
    • gcCount

      public long gcCount()
      Returns the value of the gcCount record component.
      Returns:
      the value of the gcCount record component
    • gcMillis

      public long gcMillis()
      Returns the value of the gcMillis record component.
      Returns:
      the value of the gcMillis record component
    • lock

      public LockMetrics.Snapshot lock()
      Returns the value of the lock record component.
      Returns:
      the value of the lock record component