Analyzer lj-slowest-ngx-re

Name

lj-slowest-ngx-re - Slowest find/match/split Regular Expression of ngx.re

This analyzer profiles regular expression operations in ngx.re module within OpenResty, Kong, and APISIX applications. It captures and measures the execution time of ngx.re.find, ngx.re.match, and ngx.re.split operations, identifying the slowest regex patterns that may cause performance bottlenecks. The analyzer helps optimize regex usage by revealing patterns with excessive backtracking or computational complexity, displaying results in a bar chart format with pattern strings and their maximum latencies.

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-ngx-re -p PID

# trace a shell command directly
orxray analyzer run lj-slowest-ngx-re -c SHELL_CMD

Tracing Multiple Processes

Not supported.

Output Formats

  • Bar Charts
  • Plain Texts

Output Example

[
    {
        "title": "Slowest ngx.re match patterns",
        "type": "bar",
        "series": {
            "data": {
                "base64:XmFwcDooLiop": 57677 //The regex is base64 encode as key
            },
            "name": "Max Latency (ns)"
        }
    }
]

Author

The OpenResty Inc. Team.

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