Repository navigation
Use preloaded ForkserverHelper for connector /observe reconnects - #5233
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.
Numbers first
Unprofiled wall-clock
ObservationRelayA/B benchmark (4 alternated warm rounds each after 1 untimed warm-up):SpawnedHelper)ForkserverHelper+observation_preload)RevisionObserved2422.1–2575.0 ms)240.6–257.0 ms)SidebarResult2485.0–2636.8 ms)294.3–323.4 ms)What was slow
Every remote
/observereconnect (e.g. Android Toad resuming after backgrounding or a Tailscale drop) ranConnector.helper_start = SpawnedHelper(), spawning a fresh Python interpreter from scratch:agent_comms.ui_model.observation_serviceand its module graph.comms.views.revision()callingLockedStore.load_declarations()and buildingTypedTable.schema_names(metaclass_registry._discover()importing 92 modules includingcli_bridges.*andagent_comms_hooks.*).Mechanism
ForkserverHelper(HelperStart)(src/agent_comms/execution/child_process.py): sibling ofSpawnedHelperusingmultiprocessing.get_context("forkserver")withpreloadmodule names.prepare()starts the single-threaded forkserver asynchronously (~5 ms) afterSystemdSite.start();retire()closes its alive pipe and terminates/reaps a still-preloading forkserver on server shutdown soSIGTERMnever waits out an in-flight preload or leaves an unretired old-runtime PID behind duringagent-comms install.warm_observation_forkserver()+observation_preload.py(src/agent_comms/ui_model/observation_service.py,src/agent_comms/ui_model/observation_preload.py): preloadsobservation_service, runsLockedStore.load_declarations(), buildstable.schema_namesfor every declaredTypedTablemember at finalDeclarations.generation, and freezes the heap viastarted()once in the forkserver before any/observechild forks.Connector.helper_start&ServeVerb.serve(src/agent_comms/transport/connector.py): switched toForkserverHelper((OBSERVATION_PRELOAD_MODULE,)), callingprepare()after binding andretire()infinallyafterrunner.cleanup().Verification
REL_IMPORTS=0, zero newmypyerrors on touched files.tests/test_connector_observe.py,tests/test_connector_shutdown.py,tests/test_remote_observation.py,tests/test_helper_workers.py,tests/test_package_imports.py,tests/test_runtime_server_imports.py(including< 1sSIGTERMshutdown assertion and newtest_connector_helper_start_preloads_observation_forkserver_and_retires_cleanly).