Files
taylanbakircioglu fbe223250b perf(requestlog): gate the embedded-secret scan behind a substring pre-check
The auth_pass / stats-auth / userlist / URI patterns added by the redaction
fixes on this branch run on the writer task, on every string value of every
captured body, so their cost is paid per row forever. Measured, they were:

    writer-side redaction, before the redaction fixes     12.2 us/row
    writer-side redaction, with them                     359.1 us/row

A 29x regression, and none of it was spent matching anything - almost every
body contains none of these keywords. Profiling the four patterns on an 8 KB
config body, 300 iterations:

    one combined alternation, IGNORECASE, \b-anchored    308.2 us
    the same four run separately (sum)                   219.7 us
    text.lower() once + four substring pre-checks          5.3 us

`\b` and IGNORECASE each defeat the regex engine's literal-prefix scan, so
every alphanumeric position in 8 KB became a candidate start and the engine
walked the whole body four times to find nothing. Isolated, `auth_pass` costs
27.5 us with IGNORECASE and 2.4 us without.

Split the alternation and gate each pattern behind a substring test on one
lowercased copy. `str.lower()` and `in` are C-level scans; a pattern now runs
only when its keyword is actually present, and then on text that genuinely
contains it. Cost becomes O(total string bytes) instead of O(bytes x patterns).
The URI pattern also drops IGNORECASE and `\b` - its character class already
covers both cases, and `://` gives the engine a literal to scan for.

    writer-side redaction, after                          18.8 us/row
                                                     = 3.4s of CPU/day
                                                       at 180 000 rows/day

6.6 us/row over the pre-fix baseline, for four secret classes that were
previously written to the table in cleartext.

The pre-checks are on the lowercased copy, so the patterns stay IGNORECASE: the
marker may well have been `AUTH_PASS` in the original. Request-path cost is
unchanged at 27.7 us p50 - none of this ever ran there.

All 123 redaction and payload tests still pass, so the behaviour is identical;
only the path to it is cheaper.
2026-08-15 11:04:31 +03:00
..
2025-10-27 12:14:03 +03:00
2025-10-27 12:14:03 +03:00
2025-10-27 12:14:03 +03:00
2025-10-27 12:14:03 +03:00
2025-10-27 12:14:03 +03:00
2025-10-27 12:14:03 +03:00