Analyzer lj-lua-newthread

Name

lj-lua-newthread - LuaJIT Thread Objects Allocation Flame Graph

This analyzer profiles the allocation of Lua thread objects (coroutines) in LuaJIT-based applications such as OpenResty and Kong. It captures stack traces at the point where new Lua threads are created via lua_newthread or coroutine.create. The analyzer generates flame graphs that visualize the call paths leading to thread creation, helping identify coroutine usage patterns, detect excessive thread allocation, and optimize coroutine management in Lua applications.

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-lua-newthread -p PID

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

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

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

Tracing Multiple Processes

Supported.

Output Formats

  • Flame Graphs

Author

The OpenResty Inc. Team.

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