Repository navigation
perf(supervisor): start bots without holding the supervisor lock - #80
Merged
Merged
Conversation
Writing a bot's files, building its environment block and creating its process ran under the supervisor lock, for every bot a reconcile pass started. Meanwhile every status read, MCP token check, live-text event and courier delivery waited. The pass now decides under the lock, makes the process without it and records it under the lock again. A bot deleted while it starts loses its process; a launch setting changed meanwhile restarts the new one.
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.
Second performance round, slice 1.
What
A reconcile pass used to write each bot's files (
settings.json,mcp.json, rules), build its environment block (CreateEnvironmentBlock), create the process and its Job Object, all while holding the supervisor lock, one bot after another. With Defender each start can take hundreds of milliseconds. During that time everything that reads the supervisor waited:bots.list,system.status)is_currenton every live-text eventNow each start has three steps (
supervisor/start.rs):launching.Edge cases:
startmoved out ofspawn.rs(which was over 300 lines) intostart.rs. The spec gains step 7 in 7.4.Tests
New
tests/supervisor_launch.rsuses a FakeRuntime spawn that the test holds open:supervisor.statusanswers while the process is still being made;The full suite, clippy and fmt pass.
Manual check (real Claude)
With the dev daemon, a crew of 3+ bots paused, unpause the crew. All bots reach idle as before, and the app's bot list keeps updating while they start.