Repository navigation
Commit f02b007
authored
test: Deflake memory estimation test and restore its RSS regression coverage (#2202)
`test_memory_estimation_does_not_overestimate_due_to_shared_memory`
fails intermittently on Linux CI (e.g. [this
run](https://github.com/apify/crawlee-python/actions/runs/33366608389/job/99408458117),
ratio 0.52 vs the 0.3 tolerance; previously #1288). The sharing children
only map the 100 MB segment and never touch it, so its pages are the
coldest in the process tree — under memory pressure the kernel reclaims
them first, and every reclaimed page silently leaves the PSS readings
that the phase deltas are built from.
Two changes:
1. The sharing children now fault every page of the shared segment
before the measurement. Besides removing the reclaim target, this
restores the test's original purpose: untouched mappings never enter RSS
either, so the test passed even with PSS unavailable — the exact
overcount regression it was written to catch in #1210. With this change,
a forced RSS fallback fails every round by ~11x the tolerance.
2. A distorted measurement round is retried (up to 3 rounds). Transient
reclaim does not repeat identically, while a genuine overcount misses
the expectation several times over in every round, so the retries cannot
mask it.
Verified by reproducing CI's failure signature locally under cgroup
memory pressure (`systemd-run -p MemoryHigh=` plus a hot-page churner):
2/10 failures before, 0/50 after, 0/40 idle runs, and the forced-RSS
regression still fails deterministically.
*✍️ Drafted by Claude Code*1 parent a82e6af commit f02b007
1 file changed
Lines changed: 33 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
| |||
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
257 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
258 | 262 | | |
259 | 263 | | |
260 | 264 | | |
| |||
293 | 297 | | |
294 | 298 | | |
295 | 299 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
306 | 318 | | |
307 | | - | |
308 | | - | |
309 | 319 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
314 | 327 | | |
315 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
316 | 331 | | |
317 | | - | |
318 | 332 | | |
319 | 333 | | |
320 | 334 | | |
| |||
0 commit comments