Analyzer lj-vm-states

Name

lj-vm-states - LuaJIT VM States Distribution

This analyzer profiles the distribution of LuaJIT virtual machine execution states in applications such as OpenResty and Kong. It samples the VM state during runtime, capturing time spent in different execution modes: interpreted Lua code, JIT-compiled Lua code, C functions called from Lua, garbage collection, and idle states. The analyzer generates pie chart visualizations showing the proportion of samples in each VM state, helping developers understand JIT compilation effectiveness, identify performance bottlenecks, and optimize code for better JIT performance. Higher proportions of “Compiled Lua code” indicate effective JIT compilation, while high “Interpreted” ratios may suggest JIT compilation barriers.

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-vm-states -p PID

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

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

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

Tracing Multiple Processes

Supported.

Output Formats

  • Pie Charts
  • Plain Texts

Output Example

[
  {
    "title": "LuaJIT VM States Distribution",
    "subtitle": "1000 samples in total (16% Lua-code-running samples).",
    "type": "pie",
    "id": "",
    "series": {
      "data": {
        "Interpreted": 27,
        "Compiled Lua code": 100,
        "No Lua code running": 837,
        "C code (from interpreter)": 35
      },
      "name": "LuaJIT VM State",
      "valueUnit": "Calls"
    },
    "ver": 1,
    "kind": "lj-vm-states"
  }
]

Author

The OpenResty Inc. Team.

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