Appendix: RT

Use of constant-latency blocks with preallocated memory

The design of the rendering subsystem must follow a strictly deterministic philosophy, where each processing block executes with constant latency, preallocated memory, and lock-free synchronization, ensuring predictable behavior under all real-time conditions.

This ensures that the graph maintains temporal coherence even under sustained load, preserving audio continuity and preventing degradations such as dropouts, clicks, or phase drift. The render thread forms the critical axis: it must process discrete blocks of 64, 128, or 512 samples depending on the hardware and context configuration.

Each iteration must complete within the exact duration of its quantum.

circle-info

Any interruption breaks the continuity of the audio stream. For this reason, the execution model must be deterministic and predictable, keeping graphs, internal states, and buffers in persistent and immutable structures throughout the entire render cycle.

Memory

The render thread must not perform dynamic allocations.

All buffers and auxiliary structures must be reserved during the initialization phase, remaining off the heap during processing. Preallocated pools and contiguous structures are recommended to minimize cache misses and promote consistent memory-access patterns.

Releasing memory on the render thread constitutes a real-time violation.

This principle extends to any operation that triggers retention or ARC release, even inside collections. Specialized containers —such as fixed-size arrays or preallocated stacks— must be preferred, as they encapsulate static memory and lock-free access.

The routing system must avoid underruns and overruns through explicit verification of read/write pointers and synchronization of frameCount.

All circular buffers must implement index validation and pointer resets.

Signal paths must preserve energy and phase, ensuring that subgraphs remain synchronized within the same quantum. This eliminates race conditions between nodes and enables consistent signal propagation with fully predictable temporal alignment.

Synchronization

Parallel execution must be governed by a lock-free policy, avoiding blocking.

Shared accesses must rely on atomic variables, and any update coming from the UI (control plane) must be transmitted through asynchronous one-way queues—never through busy-waiting.

The render thread must run with (SCHED_FIFO) priority, and auxiliary threads must operate at lower priority to avoid priority inversion or starvation.

In high-demand environments, the system should prevent starvation by dynamically adjusting CPU allocation and keeping critical tasks on a single logical core.

Global queues must not contend with the render thread.

circle-info

The render thread must always maintain strictly deterministic execution: no dynamic allocations, no locks, and no external dependencies.

Last updated