Class AstNodeProfiler

java.lang.Object
com.helix.profiler.node.AstNodeProfiler

public final class AstNodeProfiler extends Object
High-performance, thread-safe AST node profiler capturing per-node execution telemetry.

Emits ultra-low-overhead runtime hooks (< 5 ns) invoked directly from compiled bytecode to track execution frequency, execution latencies, failure/short-circuit rates, and cost-to-failure ratios used by adaptive AST optimizers and JFR telemetry.

  • Method Details

    • isEnabled

      public static boolean isEnabled()
    • setEnabled

      public static void setEnabled(boolean isEnabled)
    • registerNode

      public static NodeStats registerNode(String ruleName, String nodeId)
      Pre-registers a node for a given rule.
      Parameters:
      ruleName - associated rule name
      nodeId - unique node identifier
      Returns:
      initialized NodeStats
    • record

      public static void record(String ruleName, String nodeId, long elapsedNanos, boolean result)
      Direct telemetry recording helper.
      Parameters:
      ruleName - rule identifier
      nodeId - node identifier
      elapsedNanos - elapsed duration in nanoseconds
      result - evaluation outcome (false = short-circuit / failure)
    • recordEntry

      public static void recordEntry(String nodeId)
      Entry hook invoked directly from compiled bytecode prior to node evaluation.
      Parameters:
      nodeId - unique node identifier
    • recordExit

      public static void recordExit(String nodeId, boolean result)
      Exit hook invoked directly from compiled bytecode immediately following node evaluation.
      Parameters:
      nodeId - unique node identifier
      result - evaluation outcome
    • recordExit

      public static void recordExit(String nodeId, boolean result, long startNanos)
      Exit hook with explicit start timestamp.
    • getNodeStats

      public static Optional<NodeStats> getNodeStats(String nodeId)
    • getAllStats

      public static Map<String,NodeStats> getAllStats()
    • getStatsForRule

      public static Map<String,NodeStats> getStatsForRule(String ruleName)
    • emitJfrEvent

      public static void emitJfrEvent(String ruleName, String nodeId)
      Emits a custom JFR HelixNodeProfileEvent for the specified node.
      Parameters:
      ruleName - rule identifier
      nodeId - node identifier
    • emitAllJfrEvents

      public static void emitAllJfrEvents()
      Emits custom JFR HelixNodeProfileEvents for all currently recorded nodes.
    • reset

      public static void reset()
      Clears all telemetry statistics and node mappings.