perf(studio): reuse the audio mix across optimistic edits - #258
Merged
Merged
Conversation
53 tasks
LeadcodeDev
force-pushed
the
fix/studio-render-panic
branch
from
September 22, 2026 06:11
452e5aa to
70fc5c6
Compare
LeadcodeDev
force-pushed
the
perf/studio-audio-remix
branch
from
September 22, 2026 06:11
792ade6 to
5ae2fc3
Compare
LeadcodeDev
force-pushed
the
fix/studio-render-panic
branch
from
September 22, 2026 08:35
70fc5c6 to
378aaef
Compare
LeadcodeDev
force-pushed
the
perf/studio-audio-remix
branch
from
September 22, 2026 08:36
5ae2fc3 to
7c651d9
Compare
LeadcodeDev
force-pushed
the
fix/studio-render-panic
branch
from
September 22, 2026 08:45
378aaef to
d85631b
Compare
LeadcodeDev
force-pushed
the
perf/studio-audio-remix
branch
from
September 22, 2026 08:45
7c651d9 to
423648a
Compare
LeadcodeDev
changed the base branch from
fix/studio-render-panic
to
chantier/audit-2026-09
September 22, 2026 08:54
`optimistic::commit` bumps `generation` on EVERY mutation (one per `oninput` event), and `use_hot_reload` polls it every 250 ms, so a slider drag on a scenario that has audio calls `audio::prepare` ~4x/second. `prepare` spawns a brand-new `std::thread` that runs `mix_audio_tracks` over the whole scenario — documented in audio.rs:158 as "seconds on a long scenario" — decoding and resampling every track from scratch even though a font-size edit cannot have changed the audio. `MIX_TOKEN` only discards the RESULT; nothing cancels the work. Dozens of concurrent decode threads pile up, each holding a full interleaved f32 PCM buffer (~23 MB for 60 s stereo), fighting the 2-6 prefetch render workers for cores during exactly the interaction that most needs to stay smooth. Refs #220
LeadcodeDev
force-pushed
the
perf/studio-audio-remix
branch
from
September 22, 2026 09:09
423648a to
967354f
Compare
LeadcodeDev
added a commit
that referenced
this pull request
Sep 22, 2026
`optimistic::commit` bumps `generation` on EVERY mutation (one per `oninput` event), and `use_hot_reload` polls it every 250 ms, so a slider drag on a scenario that has audio calls `audio::prepare` ~4x/second. `prepare` spawns a brand-new `std::thread` that runs `mix_audio_tracks` over the whole scenario — documented in audio.rs:158 as "seconds on a long scenario" — decoding and resampling every track from scratch even though a font-size edit cannot have changed the audio. `MIX_TOKEN` only discards the RESULT; nothing cancels the work. Dozens of concurrent decode threads pile up, each holding a full interleaved f32 PCM buffer (~23 MB for 60 s stereo), fighting the 2-6 prefetch render workers for cores during exactly the interaction that most needs to stay smooth. Refs #220
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Severity Low, category quality. Location:
crates/rustmotion-studio/src/editor/playback.rs:115Impact
optimistic::commitbumpsgenerationon EVERY mutation (one peroninputevent), anduse_hot_reloadpolls it every 250 ms, so a slider drag on a scenario that has audio callsaudio::prepare~4x/second.preparespawns a brand-newstd::threadthat runsmix_audio_tracksover the whole scenario — documented in audio.rs:158 as "seconds on a long scenario" — decoding and resampling every track from scratch even though a font-size edit cannot have changed the audio.MIX_TOKENonly discards the RESULT; nothing cancels the work. Dozens of concurrent decode threads pile up, each holding a full interleaved f32 PCM buffer (~23 MB for 60 s stereo), fighting the 2-6 prefetch render workers for cores during exactly the interaction that most needs to stay smooth.Fix
Only call
preparewhen the audio actually changed — compare a hash/fingerprint ofscenario.audioplustotal_durationagainst the last prepared one and return early otherwise. Optionally serialize mixing onto a single dedicated worker so a burst cannot spawn N threads.Evidence the audit read
Part of the September 2026 audit remediation chantier. Refs #220 (RM-39).