Analyzer lj-trace-stats

Name

lj-trace-stats - LuaJIT VM Trace Event Statistics

This analyzer collects comprehensive statistics on LuaJIT trace compilation events in applications such as OpenResty and Kong. It monitors trace recording, compilation, execution, and abort events, capturing metrics including trace start events, JIT-incompatible code patterns (no-jit, NYI, blacklisted), trace setup success, and flush operations. The analyzer generates table visualizations displaying detailed trace event statistics and JIT configuration parameters (maxtrace, maxrecord, hotloop, etc.), helping developers understand JIT compilation behavior, identify optimization opportunities, and diagnose performance bottlenecks in hot code paths.

Resource Category

CPU.

Application Type & Technical Stack

  • OpenResty
  • Kong
  • APISIX

Command Line Syntax

The analyzer can be invoked directly on the command-line via the orxray utility from the openresty-xray-cli software package.

Alternatively, the analyzer can also be invoked manually or automatically on the web console UI of OpenResty XRay (like on the Advanced web page).

# PID is the target process PID.
orxray analyzer run lj-trace-stats -p PID

# trace a shell command directly
orxray analyzer run lj-trace-stats -c SHELL_CMD

# PGID is the process group ID or any process's PID within the target process
# group.
orxray analyzer run lj-trace-stats -p -PGID

# trace any processes started from the specified executable path.
orxray analyzer run lj-trace-stats --exe /path/to/exe/file

Tracing Multiple Processes

Supported.

Output Formats

  • Tables
  • Plain Texts

Output Example

[{
  "type": "table",
  "ver": 1,
  "title": "LuaJIT VM Trace Event Statistics in 15sec",
  "data": [
    ["Indicator", "Metric", "Description"],
    ["start events", "0", "Total trace start events"],
    ["no-jit events", "0", "Events that cannot be JIT compiled"],
    ["blacklisted events", "0", "Trace aborts due to blacklisting"],
    ["NYI events", "0", "Trace aborts with Not-Yet-Implemented features"],
    ["error events", "0", "Errors emitted by lj_err_caller"],
    ["setup events", "0", "Trace start events eligible for JIT compilation"],
    ["flushall events", "0", "Total trace flush operations"],
    ["current trace number", "6", "Active trace count"],
    ["current trace slot number", "8", "Maximum allocated trace slots"],
    ["jit.opt.maxtrace", "8000", "Maximum trace limit"],
    ["jit.opt.maxrecord", "16000", "Maximum recorded IR instructions"],
    ["jit.opt.hotloop", "56", "Hot loop threshold"]
  ]
}]

Author

The OpenResty Inc. Team.

Copyright (C) by OpenResty Inc. All rights reserved.