Repository navigation
audio_wav: bound the queue of pending WAV conversions - #6882
Conversation
|
The queue now limits outstanding futures. One source of memory growth remains on failed conversions: I ran the following synthetic probe from the repository root with import contextlib, io, pathlib, sys, tempfile, tracemalloc
from unittest.mock import patch
sys.path.insert(0, str(pathlib.Path("tools").resolve()))
import audio_wav as m
def failed(_, src, dst):
return False, src + "\n" + "x" * 32768
with tempfile.TemporaryDirectory() as d:
for n in (128, 512):
items = [(str(i), str(i)) for i in range(n)]
with patch.object(m, "collect", return_value=(items, 0)), \
patch.object(m, "plan_outputs", return_value=(items, 0, 0)), \
patch.object(m, "find_ffmpeg", return_value="stub"), \
patch.object(m, "decode", failed), contextlib.redirect_stdout(io.StringIO()) as log:
tracemalloc.start()
rc = m.main([d, "--jobs", "2"])
peak = tracemalloc.get_traced_memory()[1]
tracemalloc.stop()
print(n, rc, peak, log.getvalue().count(" FAILED "))On Windows at The audio test file ran 41 tests on CPython 3.14.7. 24 passed and 17 skipped. The probe did not run ffmpeg. AI-assisted. |
SirKingg
left a comment
There was a problem hiding this comment.
Independent Windows review of 9c7ac76: no blocking findings. AI-assisted review.
Windows, CPython 3.11.3, ffmpeg 8.0.1; CPU only, no GPU or game data used.
python -I tests\test_audio_wav.py -v: 41 tests, 37 passed, 4 skipped. Skips require the POSIX naming path, case-distinct entries, or canonical-equivalence behavior unavailable on this volume. The Windows normcase test passed; real ffmpeg synthetic conversion and output-name/resume tests ran.- Additional inline synthetic checks with ThreadPoolExecutor: workers 1/2/64, empty input and up to 1,000 inputs, submission window, exactly-once results, worker exceptions, out-of-order completion, and cancelled-future propagation; mocked main checks at jobs 1/20 cover existing output, blocking directory, failed decode and unexpected exception. All passed. Cancellation was injected, not an operating-system interruption test.
- Base eager-submission pattern versus this head: 1,000 versus 2 submissions before first consumption with two workers (synthetic comparison).
git diff --check 1cc6e3c121969761d9dad8fdec99f19928213973..HEADandpython -I scripts\check_no_game_data.py tools\audio_wav.py tests\test_audio_wav.pypassed.
No game corpus or GPU validation performed.
|
Thanks @shdann and @SirKingg. |
|
Independent Windows check of ace4989d with CPython 3.12.8 and FFmpeg 9.0.2. The stock Two synthetic batches, with one and three workers, each counted all 15 failures, printed exactly ten nonempty diagnostics, and reported the five omitted. Both batches wrote the two successful outputs byte for byte and preserved an existing output. The serial run also checked the fallback for an empty diagnostic and reporting of a worker exception. AI-assisted. |
|
Verified at 9c7ac76: clean against current main 2dd8795; 41 tests OK under python -I (4 ffmpeg-gated skips, new queue test executes), and the new test errors on plain main where _decode_jobs doesn't exist. The submitted-minus-consumed invariant over 1000 jobs is the right guard for the bounded-window submission. Stdlib-only, synthetic fixtures. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
tools/audio_wav.py adds _decode_jobs(), which keeps at most one outstanding ffmpeg future per worker (bounded pending dict, concurrent.futures.wait(..., FIRST_COMPLETED)) instead of submitting every input up front. The failures list becomes a failed counter with ten retained diagnostic lines, so error memory does not grow with the input count. tests/test_audio_wav.py adds a real 1000-job executor window test and a failure-summary test.
Why merge
Large WAV conversion runs previously queued all jobs and retained every Future; the window bounds queue and memory while output-name planning still covers the whole input set and workers still report errors individually. Verified with real ffmpeg and synthetic PCM/Opus conversion; 38 passed, 4 skipped.
Summary
Why mergeLarge WAV conversion runs previously queued all jobs and retained every Future; the window bounds queue and memory while output-name planning still covers the whole input set and workers still report errors individually. Verified with real ffmpeg and synthetic PCM/Opus conversion; 38 passed, 4 skipped. |
Claimed in the coordination issue as: the
audio_wavitem in this claim.What and why
The executor used to submit every planned conversion before looking at a single result.
--jobslimited the running ffmpeg processes but not the queue or the number of retained Future objects. Fill a window of at most one outstanding conversion per worker, consume completed jobs, and refill it. Output-name planning still covers the entire input set, and workers still report errors individually.Tested
Review follow-up at
ace4989dda: 38 passed, 4 skipped; failed jobs retain only the ten diagnostic lines that can be printed.On
1cc6e3c121, two workers submitted all 1,000 synthetic jobs before the first result was consumed. The new regression feeds 1,000 jobs through a real two-thread executor, checks the window on each submission and verifies every result once. Existing CLI tests also exercised real ffmpeg 7.0.2 and synthetic PCM/Opus conversion.python3.12 -I tests/test_audio_wav.py— 41 run: 37 passed, 4 skipped (filesystem case/normalization or Windows-specific).git diff --checkandpython3.12 -I scripts/check_no_game_data.py tools/audio_wav.py tests/test_audio_wav.pypassed.AI-assisted: yes.
Checklist