Commit e9d3e62
perf(redis-worker): pipeline HGETALLs in MollifierBuffer.listEntriesForEnv
The stale-sweep calls listEntriesForEnv with maxCount=1000 per env per pass.
The previous implementation issued one HGETALL per runId returned by LRANGE,
serially — ~1000 round-trips per env per pass. At any meaningful drainer
backlog this dominated sweep wall-time and made the sweep run longer than its
interval (the inFlight guard then drops every subsequent tick until it
finishes).
Refactor the per-entry fetch into a single ioredis pipeline so one network
batch covers every runId LRANGE returned. Behaviour is preserved end-to-end:
- Empty/missing entry hashes are still skipped (concurrent drainer ack/fail
between LRANGE and our HGETALL DELs the hash — a runId on the queue with
no backing hash is an expected race outcome, not an error).
- Per-entry parse failures are logged and skipped without aborting the batch.
- Per-entry pipeline errors are logged and skipped (pipeline.exec does not
abort on individual command errors).
Existing tests for happy-path + empty queue + maxCount<=0 unchanged. Added a
new test characterising the torn-down-entry race (`mollifier:entries:r_a`
DEL'd between accept and listEntriesForEnv) — passes against both serial and
pipelined implementations, so it acts as a safety net for this refactor and
future ones.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent df406ff commit e9d3e62
3 files changed
Lines changed: 79 additions & 6 deletions
File tree
- .changeset
- packages/redis-worker/src/mollifier
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2341 | 2341 | | |
2342 | 2342 | | |
2343 | 2343 | | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
2344 | 2379 | | |
2345 | 2380 | | |
2346 | 2381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
255 | | - | |
256 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
257 | 265 | | |
258 | 266 | | |
259 | 267 | | |
260 | 268 | | |
261 | 269 | | |
262 | 270 | | |
263 | 271 | | |
264 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
265 | 275 | | |
266 | | - | |
267 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
268 | 301 | | |
269 | 302 | | |
270 | 303 | | |
| |||
0 commit comments