Commit e07b20b
TASK-080: tighten threadsafety_stress latency gate from 100x p99 to 20x p95
Restores meaningful regression bite on the adversarial_segments
registration latency gate (sub-test C of threadsafety_stress) without
flaking on CI scheduler noise.
Stabilisation stack applied:
* Per-thread sample buffers eliminate the previous shared
std::mutex-guarded std::vector<int64_t>::push_back from the timing
window. Lock-wait jitter from prior iterations no longer leaks into
subsequent samples' cache lines.
* New HTTPSERVER_STRESS_PIN_CPU env knob (Linux only) pins the four
writer threads to a single CPU via pthread_setaffinity_np. Counter-
intuitive but correct: writers serialise on route_table_mutex_
anyway, and single-CPU placement eliminates cross-CPU cache misses on
radix-tree node memory. Off by default; macOS / Windows: no-op.
* New HTTPSERVER_STRESS_REPEATS env knob drives N back-to-back sampling
rounds per test invocation, printing one [STATS] line per round.
Used to build per-lane noise-floor CDFs without needing to rerun the
full make-check N times. Capped at 200. When N>1 the gate is
checked against the worst-observed p95 across all rounds.
Gate redesign:
* Statistic switched from p99 to p95. p99 = top 150 samples on a
15 000-op run; a single 1 ms OS-scheduler preemption spike against
a ~10 us median gives a 100x ratio that is purely environmental.
p95 = top 750 samples and is robust against single spikes while
still catching algorithmic regressions (an O(n) traversal at 15k
items would shift the entire upper quartile). p99 is still
printed in the [STATS] line as a forensic diagnostic.
* Threshold ratio lowered from 100x to 20x. Even with the
stabilisation stack in place, the dominant noise floor on a quiet
Apple Silicon laptop is legitimate route_table_mutex_ contention,
not OS noise. 10x is infeasible without rewriting the registration
lock strategy (out of scope). 20x gives ~50% headroom over the
worst observed local 10-round sweep (13.4x), is still 5x tighter
than the pre-TASK-080 gate, and restores real bite against
algorithmic regressions.
Documentation:
* test/PERFORMANCE.md gains a "Methodology - threadsafety_stress
adversarial_segments latency gate" section with the gate table,
the per-statistic noise rationale (why p95), the per-ratio
rationale (why 20x), and the HTTPSERVER_STRESS_REPEATS workflow
for re-measuring on a flaky CI lane.
* Inline test comment updated to point at the methodology section
and record both design choices (statistic switch, threshold
choice) with their measurement evidence.
Acceptance criterion notes:
* The TASK-080 "no flake in 50 CI runs across the matrix" criterion
cannot be enforced at PR-time. Proxy used: local 10-round sweep
(worst p95 ratio 13.4x against the 20x gate, ~50% headroom).
Post-merge monitoring window covered in PERFORMANCE.md.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 52a06e0 commit e07b20b
2 files changed
Lines changed: 433 additions & 121 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
152 | 261 | | |
153 | 262 | | |
154 | 263 | | |
| |||
0 commit comments