Commit c23a305
committed
The pump does not fail to start; it finishes first, and the guard said the wrong thing
#52, and the answer is not the one the issue expected.
`timeout_ms=200` on `audiopump.spawn()` is `sink_timeout_ms` -- how long a
sink WRITE may block. It is not a start deadline, and there is no start
deadline: `thread_start` either succeeds or raises. `audiopump_live` is set on
the CALLING thread before spawn returns, so the comment in `RingDriver.spawn`
was right and the code under it was not. `running()` is `live && !finished`,
so what a bare `not mod.running()` can catch is a pump that has already
FINISHED -- and under load that is exactly what it caught. The status block at
the moment of the loss, measured under seven busy loops sharing one core:
blocks 1 bytes 9600 error 3 ("the source ran out") fault 0
The pump started, pulled the entire 0.05 s sample, reached the end of the
source and left the loop before the interpreter got its next slice. The guard
called that "the pump would not start" and fell back to the interpreter
thread. Three sessions' worth of looking at thread creation was looking in the
wrong place.
`_why_not_running()` reads the status instead of the clock, so the sentence
now names what happened -- "the pump had already finished", or the real fault
or error when there is one. A `StartFailed` of its own separates "this
afternoon's CPU" from "this graph cannot be pumped", and `note_fault` takes
`blocking=` so a transient loss is recorded without closing the door. That
last one is the issue's "make the loss recoverable", and it closes the only
path that still latched: `sample_out.py`'s outer `except`, which nothing
cleared. (Every other refusal already recovers -- `_play` tears down when no
client is left, and the teardown is what clears the block, from #45.)
**The race itself is still here, and the obvious fix is not, on purpose.**
Accepting the finished pump instead of tearing it down was written and
measured, ten runs each under identical contention:
before pump taken 96-100 of 100 (mean 98.9) audio 100/100 always
accepting it pump taken 99-100 of 100 (mean 99.7) audio 99/100 in 3 runs of 10
It takes the pump more often and loses a whole round's audio two or three
times in ten. Slower and always sounding beats faster and sometimes silent, so
the accept is left out and the lost round is written up rather than shipped.
Proved with the issue's own pinning: `tests/pump_probes/lifecycle.py cycles`
under `taskset -c 0` with seven busy loops, ten runs, 100/100 rounds produced
audio in every one. The full pump suite, 67 tests, OK.1 parent ee0efd8 commit c23a305
2 files changed
Lines changed: 88 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
83 | 130 | | |
84 | 131 | | |
85 | 132 | | |
| |||
636 | 683 | | |
637 | 684 | | |
638 | 685 | | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
639 | 692 | | |
640 | 693 | | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
641 | 706 | | |
642 | | - | |
| 707 | + | |
| 708 | + | |
643 | 709 | | |
644 | 710 | | |
645 | 711 | | |
| |||
649 | 715 | | |
650 | 716 | | |
651 | 717 | | |
652 | | - | |
| 718 | + | |
653 | 719 | | |
654 | 720 | | |
655 | 721 | | |
| |||
1399 | 1465 | | |
1400 | 1466 | | |
1401 | 1467 | | |
1402 | | - | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
1403 | 1477 | | |
1404 | 1478 | | |
1405 | | - | |
| 1479 | + | |
1406 | 1480 | | |
1407 | 1481 | | |
1408 | 1482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
410 | 417 | | |
411 | | - | |
| 418 | + | |
| 419 | + | |
412 | 420 | | |
413 | 421 | | |
414 | 422 | | |
| |||
0 commit comments