Class ThreadActivityRecorder

java.lang.Object
eu.svjatoslav.sixth.e3d.gui.ThreadActivityRecorder

public final class ThreadActivityRecorder extends Object
Low-overhead recorder of per-thread work intervals for the thread timeline display in the Developer Tools window.

Task submission sites (transform chunks, paint tiles, tile binning) and render-thread phases (orchestration, waiting, blit) record their [start, end) intervals here when enabled. The timeline component paints each thread as a row, time on the X axis, the interval kind as color — the software-renderer equivalent of a GPU frame-profiler occupancy view. Idle time is simply the absence of intervals (black).

Overhead when disabled: one volatile read per task. When enabled: two System.nanoTime() calls, one atomic increment and four array stores per task (~100 ns), negligible at hundreds of tasks per frame.

Frame parity distinguishes "current frame" work from "next frame" work in the colors: transform/paint/binning kinds come in an even and an odd variant, selected by the parity that was current when the task was SUBMITTED (captured at task creation, so overlapping frames keep their own color).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Kind: render thread blocked waiting for worker tasks.
    static final int
    Kind base: tile binning task (add frame parity 0..2).
    static final int
    Kind: render thread blitting the finished frame to screen.
    static final int
    Number of distinct kinds (three parities each for transform/paint/bin, plus 9..14).
    static final int
    Kind: continuation sub-phase: draining and merging transform chunks.
    static final int
    Kind base: paint tile task (add frame parity 0..2).
    static final int
    Kind: a pass's asynchronous continuation (drain, sort, bin, paint submission).
    static final int
    Kind: render thread orchestration (tree walk, submission, merges).
    static final int
    Kind: continuation sub-phase: depth sort.
    static final int
    Kind base: vertex transform chunk (add frame parity 0..2).
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
     
    static void
    Drops all recorded intervals and thread-row assignments.
    static int
     
    static long[]
     
    static int
     
    static boolean
     
    static byte[]
     
    static void
    record(int kind, long t0, long t1)
    Records one work interval on the calling thread.
    static int
     
    static String
    rowName(int row)
     
    static byte[]
     
    static void
    setEnabled(boolean value)
    Enables or disables recording.
    static void
    setFrameParity(int parity)
    Sets the parity (0/1) of the frame currently being prepared.
    static long[]
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • KIND_TRANSFORM

      public static final int KIND_TRANSFORM
      Kind base: vertex transform chunk (add frame parity 0..2).
      See Also:
    • KIND_PAINT

      public static final int KIND_PAINT
      Kind base: paint tile task (add frame parity 0..2).
      See Also:
    • KIND_BIN

      public static final int KIND_BIN
      Kind base: tile binning task (add frame parity 0..2).
      See Also:
    • KIND_RENDER

      public static final int KIND_RENDER
      Kind: render thread orchestration (tree walk, submission, merges).
      See Also:
    • KIND_AWAIT

      public static final int KIND_AWAIT
      Kind: render thread blocked waiting for worker tasks.
      See Also:
    • KIND_BLIT

      public static final int KIND_BLIT
      Kind: render thread blitting the finished frame to screen.
      See Also:
    • KIND_PREP

      public static final int KIND_PREP
      Kind: a pass's asynchronous continuation (drain, sort, bin, paint submission).
      See Also:
    • KIND_DRAIN

      public static final int KIND_DRAIN
      Kind: continuation sub-phase: draining and merging transform chunks.
      See Also:
    • KIND_SORT

      public static final int KIND_SORT
      Kind: continuation sub-phase: depth sort.
      See Also:
    • KIND_COUNT

      public static final int KIND_COUNT
      Number of distinct kinds (three parities each for transform/paint/bin, plus 9..14).
      See Also:
  • Method Details

    • isEnabled

      public static boolean isEnabled()
      Returns:
      true when recording is active (checked by task submission sites)
    • setEnabled

      public static void setEnabled(boolean value)
      Enables or disables recording. Enabling starts with a clean buffer and fresh thread-row assignment.
      Parameters:
      value - true to start recording
    • clear

      public static void clear()
      Drops all recorded intervals and thread-row assignments.
    • setFrameParity

      public static void setFrameParity(int parity)
      Sets the parity (0/1) of the frame currently being prepared. Called by the render thread at the start of each frame; task submission sites capture it into their tasks so overlapping frames keep distinct colors.
      Parameters:
      parity - frame parity, 0 or 1
    • frameParity

      public static int frameParity()
      Returns:
      parity of the frame currently being prepared
    • record

      public static void record(int kind, long t0, long t1)
      Records one work interval on the calling thread.
      Parameters:
      kind - interval kind (one of the KIND_* bases, plus parity for transform/paint/binning)
      t0 - interval start, from System.nanoTime()
      t1 - interval end, from System.nanoTime()
    • cursor

      public static int cursor()
      Returns:
      total number of intervals recorded since the last clear
    • capacity

      public static int capacity()
      Returns:
      ring buffer capacity
    • starts

      public static long[] starts()
      Returns:
      interval start array (index space of the ring buffer)
    • ends

      public static long[] ends()
      Returns:
      interval end array (index space of the ring buffer)
    • kinds

      public static byte[] kinds()
      Returns:
      interval kind array (index space of the ring buffer)
    • rows

      public static byte[] rows()
      Returns:
      interval thread-row array (index space of the ring buffer)
    • rowCount

      public static int rowCount()
      Returns:
      number of distinct thread rows seen so far
    • rowName

      public static String rowName(int row)
      Parameters:
      row - thread row index
      Returns:
      display name for the row ("render" for the render thread, otherwise the thread name with the e3d- prefix stripped)