Commit ab0aeaf
fix: prevent consumer starvation in lavinmqperf throughput (#1712)
## Summary
- Add `Fiber.yield` every 128k publishes when no rate limit is set,
preventing the publisher from monopolizing a shared thread and starving
consumer fibers
- Fix ack/tx_commit to use per-consumer local counters instead of the
global atomic counter, preventing deadlocks with multiple consumers and
prefetch
- Fix `RateLimiter` to use its local counter for yield frequency (was
using global counter or stuck at 0)
## Context
When running `lavinmqperf throughput` on machines with few CPU cores,
`Fiber::ExecutionContext::Parallel` has limited threads. The publisher
and consumer fibers (plus AMQP client internal fibers) can share a
thread. The publisher's tight loop with zero yielding monopolized the
thread, causing the consumer to stop reading from its socket. The
server's TCP send buffer filled up and delivery stalled permanently.
Closes #1711
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Carl Hörberg <[email protected]>1 parent 2aeac2e commit ab0aeaf
1 file changed
Lines changed: 17 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
357 | 358 | | |
358 | 359 | | |
359 | 360 | | |
| |||
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
386 | | - | |
| 387 | + | |
| 388 | + | |
387 | 389 | | |
| 390 | + | |
388 | 391 | | |
389 | 392 | | |
390 | 393 | | |
| |||
418 | 421 | | |
419 | 422 | | |
420 | 423 | | |
| 424 | + | |
421 | 425 | | |
422 | | - | |
| 426 | + | |
| 427 | + | |
423 | 428 | | |
424 | 429 | | |
425 | 430 | | |
426 | 431 | | |
427 | | - | |
| 432 | + | |
428 | 433 | | |
429 | 434 | | |
430 | 435 | | |
431 | 436 | | |
432 | | - | |
433 | | - | |
| 437 | + | |
| 438 | + | |
434 | 439 | | |
435 | 440 | | |
436 | 441 | | |
437 | | - | |
| 442 | + | |
438 | 443 | | |
439 | 444 | | |
440 | 445 | | |
| |||
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
| 461 | + | |
456 | 462 | | |
457 | 463 | | |
458 | 464 | | |
| 465 | + | |
459 | 466 | | |
460 | | - | |
| 467 | + | |
461 | 468 | | |
462 | 469 | | |
463 | 470 | | |
| |||
492 | 499 | | |
493 | 500 | | |
494 | 501 | | |
495 | | - | |
| 502 | + | |
| 503 | + | |
496 | 504 | | |
497 | 505 | | |
498 | | - | |
499 | | - | |
| 506 | + | |
500 | 507 | | |
501 | 508 | | |
502 | 509 | | |
503 | 510 | | |
504 | | - | |
505 | 511 | | |
506 | 512 | | |
507 | 513 | | |
| |||
0 commit comments