refactor: AppProxy wake-on-send via MainThreadPoster#14
Merged
Conversation
AppProxy scheduled cross-thread work onto the main thread by draining an mpsc channel from a foreground task that woke every 16ms via a background timer. That poll loop was flagged as a wart: an idle tray app paid a fixed wakeup cost forever, purely because the fork had no dependency-free way to wake the main thread from a Send context. The fork now provides that primitive. App::main_thread_poster hands back a Clone+Send+Sync MainThreadPoster whose post() enqueues a closure and wakes the run loop through the platform dispatcher, so an idle app stays parked. Back AppProxy with the poster and delete the timer loop. The shutdown boundary stays ours: a `closed` AtomicBool, set at ShutdownRequested (which precedes app teardown), is checked in dispatch and re-checked inside each posted closure on the main thread. Since close() also runs on the main thread, any closure the pump dispatches after close() drops its payload, preserving the old drain loop's discard-after-close contract. The poster's own after-teardown false is a second layer, not a replacement. Pins gpui/gpui_platform and the vendor submodule to 2ee4fa6 (gpui#7). The workspace version and COMPATIBILITY.md bump is deferred to merge time via /update-gpui discipline.
gpui PR #7 merged; fork main is now 2a03ae6e (squash of the poster commit 2ee4fa6). Point the gpui/gpui_platform revs and the vendor/gpui submodule at fork main. Bump the workspace version 0.5.1 -> 0.6.0: a gpui rev change is a minor bump while pre-1.0, per the compatibility discipline. Sync the [workspace.dependencies] path-crate version requirements, plus the hardcoded [package] versions in ui/macros/assets that do not inherit version.workspace. Add the 0.6.0 row to docs/COMPATIBILITY.md. The annotated tag v0.6.0 is created at merge time, not here.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
Disabled knowledge base sources:
Summary by CodeRabbit
WalkthroughThe release updates the workspace and crates to 0.6.0 with a new gpui revision. AppProxy now uses MainThreadPoster for push-based main-thread dispatch, atomic shutdown checks, and revised runtime tests. ChangesAppProxy and 0.6.0 release
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant AppProxy
participant MainThreadPoster
participant MainThread
Caller->>AppProxy: dispatch(callback)
AppProxy->>MainThreadPoster: post guarded callback
MainThreadPoster->>MainThread: execute posted callback
MainThread->>AppProxy: re-check shutdown flag
MainThread-->>Caller: run callback when open
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
What
Replace the
AppProxypoll loop with aMainThreadPoster, so cross-thread work wakes the main thread on send instead of being drained by a fixed 16ms timer. Removes idle wakeups and the up-to-16ms latency floor on posted work.Re-pin
gpui PR #7 merged; fork main is now
2a03ae6e(squash of the poster commit). This bumps thegpui/gpui_platformrevs and thevendor/gpuisubmodule to fork main.Per the compatibility discipline, a gpui rev change is a pre-1.0 minor bump: workspace version
0.5.1→0.6.0, with the[workspace.dependencies]path-crate versions synced and a newdocs/COMPATIBILITY.mdrow. The annotated tagv0.6.0is created at merge time, not in this PR.Supersedes the auto-closed PR #11 (its base
feat/app-platformmerged to main); non-draft now that its precondition landed.Gates (local)
cargo test -p gpui-component-app(52 passed, incl. 3gpui::testbehavior tests + headless), workspaceclippy --all-targets -- --deny warnings,fmt, both examples--smokeexit 0.