test(scratch): leak-hunt probes for cava, render loop, decode stream

One-off diagnostics behind the FFTW leak fix: init/destroy x50 RSS
bound, Mach VM region walker, render-churn region growth, ffmpeg
decode-stream region/rss sampling.
This commit is contained in:
2026-09-06 18:46:42 -04:00
parent 6c3ad5d925
commit b53d4add29
5 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
/** Scratch runner: decode stream, self-measure VM regions over time. */
import { EpisodePcmCache } from "../src/utils/audio-pcm-cache"
import { countRegions } from "./scratch-region-count"
const wav = "/tmp/podtui-stream.wav"
if (!(await Bun.file(wav).exists())) {
await Bun.$`ffmpeg -f lavfi -i "sine=frequency=440:duration=600" -ar 22050 -ac 1 -sample_fmt s16 ${wav}`.quiet().nothrow()
}
const pcm = new EpisodePcmCache({ url: wav })
Bun.gc(true)
console.log(`start: ${JSON.stringify(countRegions())}`)
pcm.startDecode(0)
const t0 = Date.now()
const buf = new Float64Array(512)
while (Date.now() - t0 < 90_000) {
await Bun.sleep(15_000)
const pos = ((Date.now() - t0) / 1000) * 4
pcm.readWindow(buf, pos)
const c = countRegions()
console.log(`t=${((Date.now() - t0) / 1000) | 0}s total=${c.total} r128k=${c.r128k} rss=${(process.memoryUsage.rss() / 1048576) | 0}MB`)
}
pcm.stop()
console.log("done")