coreruleset: time worst-case inspections against reference work (closes #400) #402

Open
clawbot wants to merge 1 commits from issue-400-coreruleset-timing-ref into next
pull from: issue-400-coreruleset-timing-ref
Collaborator

Closes #400

TestTheCoreRuleSetInspectsEachWorstCaseRequestInTime compared each inspection with a fixed 1 second, so a busy host failed make check at random. As decided on the issue, it now compares each inspection with reference work: a fixed regular-expression match, unrelated to the Core Rule Set, timed on the same thread just before and after. Both are timed in processor time (CLOCK_THREAD_CPUTIME_ID, with the goroutine locked to its thread), so time other programs hold the processor does not count. A busy host's lower clock speed and shared cores slow both alike.

The limit is 13 times the mean reference time. How 13 was fitted, over five make test runs on our check host with test-race running alongside and load averages from 45 to 125:

  • The reference work took 78 to 127 ms. 13 × 78 ms is about 1 second, the old limit.
  • No try of the slowest worst-case request took more than 9.5 times the reference.
  • A request still fails only when all three tries are over the limit.

A Core Rule Set about 1.4 times slower on that request fails the test.

golang.org/x/sys moves from indirect to direct, for unix.ClockGettime; syscall does not export it.

Judgement call: 13 is fitted to one host. On a much faster or slower processor the ratio, not the seconds, is what holds.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/smallwebwaf/issues/400 `TestTheCoreRuleSetInspectsEachWorstCaseRequestInTime` compared each inspection with a fixed 1 second, so a busy host failed `make check` at random. As decided on the issue, it now compares each inspection with reference work: a fixed regular-expression match, unrelated to the Core Rule Set, timed on the same thread just before and after. Both are timed in processor time (`CLOCK_THREAD_CPUTIME_ID`, with the goroutine locked to its thread), so time other programs hold the processor does not count. A busy host's lower clock speed and shared cores slow both alike. The limit is 13 times the mean reference time. How 13 was fitted, over five `make test` runs on our check host with `test-race` running alongside and load averages from 45 to 125: - The reference work took 78 to 127 ms. 13 × 78 ms is about 1 second, the old limit. - No try of the slowest worst-case request took more than 9.5 times the reference. - A request still fails only when all three tries are over the limit. A Core Rule Set about 1.4 times slower on that request fails the test. `golang.org/x/sys` moves from indirect to direct, for `unix.ClockGettime`; `syscall` does not export it. Judgement call: 13 is fitted to one host. On a much faster or slower processor the ratio, not the seconds, is what holds. Model: opus-5-5
clawbot added the needs-review label 2026-11-16 08:55:38 +01:00
clawbot self-assigned this 2026-11-16 08:55:38 +01:00
clawbot added 1 commit 2026-11-16 08:55:38 +01:00
The worst-case inspection test compared each inspection with a fixed 1
second, so a busy host failed it at random. It now times, on the same
thread and in processor time, a fixed regular-expression job just
before and after each inspection. An inspection fails when it takes
more than 13 times that job, about 1 second on an idle host.

Model: opus-5-5
All checks were successful
check / check (push) Successful in 6m24s
You are not authorized to merge this pull request.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-400-coreruleset-timing-ref:issue-400-coreruleset-timing-ref
git checkout issue-400-coreruleset-timing-ref
Sign in to join this conversation.