Analyzer lj-slowest-str-gmatch

Name

lj-slowest-str-gmatch - Slowest Lua string.gmatch

This analyzer profiles the performance of Lua’s string.gmatch iterator function in LuaJIT-based applications such as OpenResty and Kong. It measures the latency of pattern matching operations performed by string.gmatch, identifying patterns that exhibit the highest execution time. The analyzer generates histogram and bar chart visualizations displaying maximum latency per pattern, enabling developers to detect inefficient regular expressions and optimize iterative string processing workflows.

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-gmatch -p PID

# trace a shell command directly
orxray analyzer run lj-slowest-str-gmatch -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-gmatch -p -PGID

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

Tracing Multiple Processes

Supported.

Output Formats

  • Bar Charts
  • Histogram Bar Charts
  • Plain Texts

Output Example

[
  {
    "kind": "",
    "series": {
      "categoryTitle": "Latency",
      "categoryUnit": "ns",
      "data": {
        "8": 1,
        "4096": 8,
        "16384": 1
      },
      "name": "Calls"
    },
    "subtitle": "10 Calls (min: 5008 ns, avg: 7003 ns, max: 30671 ns)",
    "summary": {
      "avg": 7003,
      "cnt": 10,
      "max": 30671,
      "min": 5008
    },
    "title": "Lua Slowest string.gmatch Distribution",
    "type": "dist-bar",
    "ver": 1
  },
  {
    "series": {
      "data": {
        "\"%a+\"": 30671,
        "\"(%d+)%.(%d+)\"": 8192,
        "\"[^,]+\"": 5008
      },
      "name": "Max Latency (ns)"
    },
    "subtitle": "",
    "title": "Lua Slowest string.gmatch Patterns and Corresponding latency",
    "type": "bar",
    "ver": 1
  }
]

Author

The OpenResty Inc. Team.

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