Skip to content

Log line matcher shows slow performance in failure #823

@natecook1000

Description

@natecook1000

As reported on the forums, a matcher a log line like this can have poor performance when failing to match:

[2025-09-01 12:34:56.789] [TRACE] [net.http] (1442) anna.smith+test@example.com | https://example.com | {"id": 42, "name": "Widget", "price": 12.50, "tags": ["swift","regex","benchmark"]} | let foo = 123; let bar = foo + 456 // sum | This is is a test with a repeated word word for backreference. | 0.0.0.0

The pattern in the post is written as RegexDSL, and translates to this pattern:

let logLine = #/
  (?:
    (?m:^)
    \[
      \d{4}-\d{2}-\d{2}
      \s
      \d{2}:\d{2}:\d{2}
      \.
      \d{3}
    \] \[
    (TRACE|DEBUG|INFO|WARN|ERROR)
    \] \[
      \w+
      (?:\.\w+)*
    \] \(
      \d+
    \)
    \s+
    [(?s:.)]*?
    (?m:$)
  ){8}
  /#

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMatching time doesn't meet expectations

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions