Commit e42586b8 by PLN (Algolia)

fix(perf): Pulsar stays fast in every mode — the editor IS the instrument

perf-audio deprioritized Pulsar to nice 10 in cool/extreme and nice 5 in
standard, on the theory that the editor should yield to audio. That trade buys
nothing. The entire audio chain runs SCHED_FIFO *above* it — scsynth 90,
sclang 85, PipeWire 95, WirePlumber 95, Ardour 80 — and a realtime policy
preempts every CFS nice level unconditionally. So Pulsar at -5 cannot take a
single cycle from SuperDirt; it only wins against ordinary processes (browsers,
indexers, builds), which is exactly what we want during a composing session.

Now nice -5 in every mode, overridable with PULSAR_NICE=NN (0 = neutral,
positive = the old behaviour). -5 rather than 0 because the renderer is a single
JS thread and its work is bursty: it has to win the CPU on the tick after a
keystroke, then yield. No root needed — @audio's `nice -19` grant in
/etc/security/limits.conf is what makes the same renice work for pln.

Validated: installed to /usr/local/sbin/perf-audio, re-applied via
`bridge.py perf standard`, all Pulsar processes confirmed at nice -5 live.
parent 16c09aa1
...@@ -659,21 +659,26 @@ set_priorities() { ...@@ -659,21 +659,26 @@ set_priorities() {
fi fi
if [ ! -z "$PULSAR_PIDS" ]; then if [ ! -z "$PULSAR_PIDS" ]; then
if [ "$mode" != "standard" ]; then # Pulsar is the INSTRUMENT, not background load, so it stays fast in EVERY
# Extreme/cool: low but NOT idle — keeps editor usable while livecoding # mode. The old policy (nice 10 in cool/extreme, nice 5 in standard) cost
for PID in $PULSAR_PIDS; do # real editor latency and bought no audio headroom, because the entire audio
renice -n 10 -p $PID >/dev/null 2>&1 # chain runs SCHED_FIFO above it: scsynth 90, sclang 85, PipeWire 95,
ionice -c 2 -n 6 -p $PID >/dev/null 2>&1 # WirePlumber 95, Ardour 80. A realtime policy preempts EVERY CFS nice
done # level, so Pulsar at -5 cannot take a single cycle from SuperDirt — it only
echo "✓ Set Pulsar processes to low priority (nice 10, best-effort I/O 6)" # wins against other ordinary processes (browsers, indexers, builds), which
else # is exactly what we want during a composing session.
# Standard mode: slightly lower #
for PID in $PULSAR_PIDS; do # -5 rather than 0 because the renderer is single-threaded and its work is
renice -n 5 -p $PID >/dev/null 2>&1 # bursty: it must win the CPU on the very next tick after a keystroke, then
ionice -c 2 -n 5 -p $PID >/dev/null 2>&1 # yield. Needs @audio's `nice -19` grant in /etc/security/limits.conf —
done # which is also why the same renice works for pln without root.
echo "✓ Set Pulsar processes to slightly lower priority (nice 5)" #
fi # Override with PULSAR_NICE=NN (0 = neutral, positive = the old behaviour).
for PID in $PULSAR_PIDS; do
renice -n "${PULSAR_NICE:--5}" -p $PID >/dev/null 2>&1
ionice -c 2 -n 2 -p $PID >/dev/null 2>&1
done
echo "✓ Set Pulsar to HIGH priority (nice ${PULSAR_NICE:--5}, I/O best-effort 2) — editor stays reactive"
else else
echo "ℹ️ Pulsar processes not found - skipping" echo "ℹ️ Pulsar processes not found - skipping"
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment