Analyzer lj-slowest-str-gsub

Name

lj-slowest-str-gsub - Slowest String Global Substitution For Lua’s string.gsub

Profiles LuaJIT’s string.gsub performance in OpenResty/Kong applications. Measures execution time of global string substitution operations, identifying slow patterns and replacement logic. Generates histogram and bar chart visualizations showing the slowest operations with maximum latency, helping optimize string manipulation and reduce CPU overhead.

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-slowest-str-gsub -p PID

# trace a shell command directly
orxray analyzer run lj-slowest-str-gsub -c SHELL_CMD

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

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

Tracing Multiple Processes

Supported.

Output Formats

  • Bar Charts
  • Histogram Bar Charts
  • Plain Texts

Output Example

[
  {
    "title": "Lua Slowest string.gsub Distribution",
    "subtitle": "2 Calls (min: 10534 ns, avg: 10625 ns, max: 10717 ns)",
    "type": "dist-bar",
    "ver": 1,
    "series": {
      "data": {
        "2048": 0,
        "4096": 0,
        "8192": 2,
        "16384": 0,
        "32768": 0
      },
      "categoryUnit": "ns",
      "categoryTitle": "Latency",
      "name": "Calls"
    },
    "summary": {
      "avg": 10625,
      "max": 10717,
      "min": 10534,
      "cnt": 2
    },
    "kind": "lj-slowest-str-gsub"
  }
]

Author

The OpenResty Inc. Team.

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