Run each application instance on its own dedicated thread (ADR 0009) - #159
Merged
Merged
Conversation
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.
Why
Every instance future ran on the shell's shared multi-thread runtime. Each instance iteration is one long synchronous poll body — select, shape lines, update the view, submit — and tokio can't preempt synchronous work, so in debug builds an instance under an output burst starved the desktop completely.
mtcarried an unconditionaltask::yield_now()per iteration as a mitigation, which is overhead when the desktop is idle and not a real fix.Summary
massive <id>) with its own tokio runtime, built inside the thread closure so the runtime's lifetime enclosesblock_on(dropping it early would abortspawn_blockingpty readers).ApplicationgainedRuntimeKind(CurrentThreaddefault,MultiThreadopt-in for instances with internal parallelism) viaApplication::with_runtime_kind; the desktop exports it.TaskContext— including the shaping context — is created on the desktop task and moved into the thread explicitly, since the instance thread runs outside the desktop's task-locals.join_next()drains; shutdown stays cooperative and the process end reaps unresponsive threads.join_nextinstead of hanging it.panic-messagecrate (zero dependencies, mirrors rustc's own unpacking logic) instead of a hand-rolled downcast chain.Validation
cargo check -p massive-desktop,cargo fmt --check -p massive-desktopcleancargo test -p massive-desktop: 46 passedcurrent_threadruntime runsblock_onwith timers and cross-thread wakes (ADR 0009, "Considered options")Assisted by an AI coding agent.