fix: disable Python garbage collector to prevent 1s periodic audio pops
CI / test (push) Has been cancelled

Default GC threshold (700 allocs) triggers ~every 1.4s in the
real-time audio callback due to ~500 numpy allocs/sec. Each GC
pause (10-50ms) exceeds the 5.3ms callback window at 256/48k,
producing audible pops at ~1Hz intervals.

Reference counting handles 99% of object cleanup — GC only handles
cyclic garbage. Disabling it is safe for a process that exits cleanly
(os reclaims everything).
This commit is contained in:
2026-06-18 18:23:01 -04:00
parent 017a74a414
commit 6495facb02
+12 -1
View File
@@ -838,7 +838,18 @@ def main() -> int:
except Exception as exc:
logger.warning("Could not set CPU governor (non-root?): %s", exc)
import argparse
# Disable Python garbage collector to prevent 10-50ms GC pauses in
# the real-time audio callback. At ~500 numpy allocs/sec in the
# pipeline, default GC (threshold=700) triggers every ~1.4s,
# causing audible pops. Reference counting handles 99% of cleanup.
try:
import gc
gc.disable()
logger.info("GC disabled for RT audio stability")
except Exception as exc:
logger.warning("Could not disable GC: %s", exc)
logger.info("Pedal v2 starting up...")
parser = argparse.ArgumentParser(
description="Pi Multi-FX Pedal — real-time guitar multi-effects",