Repository navigation
state_exec_bench: pool_aging records where its kernels ran and each call's legs - #1262
Merged
Merged
Conversation
The declarations threaded Stage 1b's implementers share (S1.md S1.9-S1.11, S1-Q12), with stubs that keep today's behaviour: - Runtime::drain_begin()/drain_end() and AppRuntime's pair: drain() in two halves around app.exec_pump_frame(). Stubs: drain_begin does nothing, drain_end is today's drain(). - register_action_intrinsics(provider, provider_affinity); the one-argument form is host_only. The stub ignores the kind. - AppRuntime::declare_thread_affine_prefix (recorded) and AppRuntime::wait_idle (the app's host); pycvc's AriApp.wait_idle goes through it. - Runtime::isolated_group() and isolation_reason(), for ariadne.exec.isolate_documents (S1-Q6). - ictx.host in every Ariadne lane: an action and its spawned children get the app's async host (the one providers use today), the init lane its own inline host (S1-Q2), load_names' probe an inline host, so a provider can register on *ictx.host everywhere. - CTest entries ariadne_runtime_test_threads_auto and ariadne_host_test_threads_auto (AR-1): both suites again with CVC_EXEC_THREADS=auto, AppLockManager.* left out.
…'s host Threaded Stage 1b, S1.9's ariadne.cpp and app_runtime.cpp rows (S1.md; td 4.9; S1-Q2, S1-Q7): - The provider registry keeps each provider's kind; the one-argument register_action_intrinsics is host_only. install_providers puts the providers into a program's env by kind: in group 0, a host-affinity group, the init lane and the name probes every provider runs as it is; in an `any` group an `any` provider runs as it is, a `host_only` one is not run (its names are NameErrors), and a `host_proxied` one runs into a scratch scope over the env, whose natives then go in through exec_group::install(..., host_proxied) and whose other bindings are copied. The design is documented beside the registry. (No group exists until S1.10, so every caller passes none here.) - AppRuntime's one provider becomes four, registered with their kinds: the host's verbs and functions (host_only), quit and the data-* verbs (host_proxied), the async verbs (any) and the host's async functions (host_only). The async ones register on *ictx.host; their done channels post to ictx.host->parking_scheduler(), captured as the env is built, or to group 0 from an inline host (the init lane). The data-* provider's own-program probe walks the tree pinned, since a spawned child builds its env on its pumping thread. - AppRuntime::idle() and wait_idle() also read the document's group (Runtime::isolated_group(), null until S1.10). - The init lane's private scheduler gets its own cycle registry, declared before it and collected when the run ends. Tests: - AriadneInit.ItsCyclesAreItsOwnAndFreedWhenItEnds: fails without the init registry (65 objects left in the thread's own registry). - AriadneHostVerbs.AnInitLanesAsyncVerbPostsItsDoneChannelToGroupZero: the inline host's done channel still reaches group 0.
S1.md S1.9's stream rows (td 4.9; S1-Q7): - stream_params gains `scheduler` (appended; null keeps group 0, the app's exec scheduler). The stream takes it at open and posts its seq and lifecycle events there, from the producer thread too, instead of ctx_.exec_scheduler(). - (stream-open) passes the calling program's group, ictx.host->parking_scheduler(), or null (an inline host: group 0). The stream verbs' provider is `any`: mutex-guarded tables, descriptors written through pinned walks, posts to the opener's group; its body reads only the context. - room-subscribe's proxy opens on the caller's group (an internal subscribe_on; the public room_subscribe keeps its signature and group 0, as stream_bridge and stream_relay do). - descriptor_pins_ is a cvc::pin_vector, so the descriptor's chain is released leaf first (K's PIN-1, StreamDescriptorPinsReleaseTheLeafFirst). Tests: Stream.EventsGoToTheSchedulerItWasOpenedWith (live, a seq posted from another thread and closed reach the named scheduler, none the app's), AriadneStreamIntrinsics.AStreamPostsToItsOpenersGroup (a stream opened from a context whose host parks on another scheduler posts there, not to group 0) and AriadneStreamIntrinsics.AStreamOfAnInlineHostPostsToGroupZero (the fallback).
S1.md S1.9's net rows (td 4.9, B30; S1-Q7): - The verbs register on the calling program's async host, *ictx.host (S1b.0 set it in every lane), not app.exec_async_host(): group 0's for a document in group 0, its group's for an isolated one, init's inline host on the init: lane. A started request (http_work, uri_fetch_work) keeps the host it started on and is finished there (settle_started); a host's shutdown, which a group's teardown makes after its kills, cancels each call it started, and a cancelled call is never finished on it, so nothing a started request needs dies before it. - Two providers by kind: `any` (http-get, http-request, fetch, ws-*, net-allowed?, net-auth-*) and `host_proxied` (open-url). The credential store locks: every CredentialStore member that reads or writes its entries, bindings or renewers holds its mutex_, and the policy is immutable once the host made it, so net-allowed? and net-auth-* go with the requests. Both registration bodies read only the context and the atomic `live`, and bind natives into the new env. Tests: AriadneNetIntrinsics.RequestsGoThroughTheContextsHost (a request is a kernel of the context's host, and the app's host never sees it) and AriadneNetL4.AStartedRequestKeepsTheHostItStartedOn (a started request is finished on its host, and that host's shutdown aborts it), both against a context whose host is not the app's (use_host_in_contexts).
…ompute S1.md S1.9's remaining provider rows (S1-Q7), each registered with the two-argument register_action_intrinsics: - room and room-media: host_proxied (raw walks and writes of the app-global room tree, a room_handle used outside room_table's lock, the bridge). - oidc: host_proxied. Its completion still posts to group 0 (oidc#NAME): a document that uses oidc is never isolated (S1-Q6). - nav_compute: (nav-step) on *ictx.host, `any`: its marshal touches nothing and its kernel runs on the background pool over the warmed compute pool, returning a fresh string. Its headless twin, AriadneAction.NavStepAsAnAsyncFunctionReturnsItsResult, registers the same way. Every registration body reads only the context (and a weak host or an atomic) and binds natives into the new env, so a spawned child may run it on a worker.
state_resolve and state_store pin the addressed node and its chain, and may run on a compute-pool worker. The chain was a std::vector, released root first, declared after the node it held, and the node itself was a copy that outlived the chain: once another thread unlinked the subtree, the pins were its last owners and an ancestor died before its child (a destroyed() slot may walk _parent). `chain` and `effective::pins` are cvc::pin_vectors (td 4.8). `pins` is declared before `node`, and the node and its chain both move into `effective`, so the node goes first, then the chain leaf first. For a followed transparent link the link node and its chain are let go of in that order before the result is returned, since parameters go in no set order. K's PIN-1 (UriStateChainsReleaseTheLeafFirst) proves it.
The signals2 subscribers of S1-Q7's table, audited for writers on a worker (td 4.8, B15). - The not-thread-safe cvcGL subscribers (CameraController, TouchGestures, StageLighting, FpsHud, ScreenTextHud, and Settings.cpp's ShadowSettings, UiSettings and ViewportLayout) record the thread that built them, so connected them, and assert in handleStateChanged that a state change reaches them there. Debug builds only; the member is unconditional, so a class's layout never depends on NDEBUG. A test that leaks one onto a worker fails in CI's Debug cvcGL jobs. - GraphicsNode::handleStateChanged runs on the writing thread and checks for its echo before it marshals. The own-publisher check reads only thread-local state on a worker. The scene-less check read a plain member flag that the node's own thread sets around its direct pose write: another thread's matrix write meanwhile (a worker-pumped group's, or a publisher flushing a pose queued before the node lost its scene) raced it and, reading true, was dropped as the echo while the tree ended on it. The mark is now the writing thread's (a thread_local, as state_publisher's flushing() is), so only the inline echo is dropped and another thread's write is marshalled. cvcgl_unattached_node_thread's new case fails without it. - state_sync_adapter stays not thread-safe (S1-Q7): its slots re-walk from the root with raw, creating lookups and read _attached unlocked. Comments say only host-thread writers reach the replicated subtree (conf.*) in Stage 1, and name the follow-up (pinned walks, an atomic flag).
In arigl the scene prefix is the document's, and the camera, touch, lighting, HUD and settings subscribers under it assume the render thread. AriRuntime declares that prefix to its AppRuntime before any load (AppRuntime::declare_thread_affine_prefix, S1.11), so an isolated document there is pumped on the host thread (S1-Q6). AriRuntime::wait_idle goes through AppRuntime::wait_idle, which also waits for the document's own group host once the document is isolated.
…ead-affine prefix
PIN-1 (S1.md section 4; S1.9, S1.11; td 4.8), at the end of state_lifetime_stress_test.cpp under the Stage 1b banner, modelled on ContextRootPinsReleaseTheChrootFirst: - StateLifetime.UriStateChainsReleaseTheLeafFirst: a state:// store whose write fires a slot that removes the node's parent is the last owner of both; the node dies with its parent alive, for the node itself and through a transparent link. - StateLifetime.StreamDescriptorPinsReleaseTheLeafFirst: a stream whose document subtree was removed while it was open is the last owner of its descriptor chain when it closes; stats, the descriptor and streams each die before their parent. Both fail on S1b.0 with MSVC (its std::vector releases front first, root first). libc++ destroys a vector back to front, so the stream case may pass there before the fix; the uri_state case fails on all three standard libraries, since the store's own node pin outlives its chain.
register_net_intrinsics no longer holds the app or its async host: each program calls through its own context's host, and the verbs are two providers by kind. AriRuntime::wait_idle waits on the document's group host too (AppRuntime::wait_idle).
async_scheduler::ingress_posts_for_test() counts the post_message() and post_async_completion() calls a scheduler has taken, from any thread. AR-3b reads it to show an isolated document's providers post to its own group and leave the app scheduler's ingress untouched (S1.md section 4).
Threaded Stage 1b, S1.10 (S1.md; td 4.12, 4.15; S1-Q6, S1-Q7, S1-Q8): - The drain splits. Runtime::drain_begin() is the drain up to the pump (oidc, key bindings, images, the queued events and host handlers, ticks, input residents) plus has?'s snapshot for an `any` group; drain_end() is the pump, skipped when app.exec_pump_generation() moved since this Runtime's drain_begin(), then the sweep. drain() is both, and drain_end() alone runs drain_begin() first. AppRuntime's pair puts the scene work, warnings and frame hooks after drain_end(). starts_frame() and the pump clock stay on the drain() path. - Host-thread calls: post_input, post_signal and render assert, in debug builds, that no pump_all of the app's pool is running on the calling thread (through exec_pool_probe(), which never builds the pool). ariadne.h's post_input and post_signal comments say "host thread, outside a pump" instead of thread-safe. - Isolated documents (ariadne.exec.isolate_documents, "1" or "true"): the placement is decided at load (AppRuntime::load asks at its end; a bare Runtime decides at its first drain, render, submission or isolated_group() query after set_root), and again for each document set_root gives. S1-Q6's rules, in order: a non-empty prefix; an enforced (strict) channel policy with no global channel and no static '/' channel in any program; no oidc (an oidc-* call or the oidc# channel); no writable link: hole whose target leaves the prefix. An eligible document gets an exec_group (owner and name its owner tag, a frame group of the app), `host` when a host_only provider binds anything in its env or a declared thread-affine prefix is at or under its prefix, else `any`; an ineligible one stays in group 0 and logs why once. Actions, residents, ticks, input, signals, kills, the sweep and has? use its scheduler and host; providers install by kind; drain_end() pumps the group through the app's pool when no frame pump did. A document whose placement changes moves: its processes are killed and reaped where they ran, run_program callers are told, its residents start again in the new place, and the old group is kept (empty, still drained) until the Runtime goes, since a stream it left open posts to it. Runtime::declare_thread_affine_prefix (new) takes AppRuntime's declarations. - spawn_child builds the child's context from its parent's (scheduler, host, root, root_pins, root_path, identity, channel policy, document scope, lock fields, spawn context), with no re-chroot by path, so a child of a deleted chroot writes its parent's detached node; nothing in it walks the tree, since it runs on the pumping thread. - Teardown (~Impl), each step catching and logging what it throws: doc_scope_.clear(); kill_owner and the reap of every process the Runtime knows of, its actions' own included (S1-Q8); then the group (unregistered from the frames first) and any earlier group. Tests: - AriadneScheduler.DrainEndDoesNotPumpAgainAfterAFramePump: with drain_begin, exec_pump_frame, drain_end an await resumes once a frame (4 after 5 frames; 9 when drain_end pumps again). - AriadneIsolatedDocs.ProvidersAreInstalledByTheirKind: in an `any` group at 2 threads with CVC_EXEC_FORCE_MOVE, a host_proxied native runs only on the frame thread and its constant is bound, an `any` native also runs on a worker, and a host_only provider registered after the group is made is a NameError that has? does not see (all three fail with every kind installed as it is). - AriadneIsolatedDocs.IdleAndWaitIdleCountTheDocumentsGroup: idle() is false while the document's kernel runs on its group's host, and wait_idle() waits for it (both fail without S1.9's reads of the group). - AriadneIsolatedDocs.TeardownReapsItsProcessesAndDestroysItsGroup: a parked action and its fork in a group; after the Runtime goes no group of the app is alive and a frame pump finds none. - AriadneIsolatedDocs.ALaterDocumentThatIsNotEligibleMovesToGroupZero: a later tree with a writable hole out of the prefix moves the document to group 0; its resident is reaped in the group and starts again in group 0, and the hole is writable (fails when the placement is decided only once). - AriadneHazards.HZ08_ForkedChildKeepsOwnerAndTeardownReapsIt, reworked (S1-Q8): after teardown the action's own process is gone too (fails without reaping it).
Threaded Stage 1b's Ariadne cases (S1.md section 4; td 8.5, 8.6), written from td and the plan against S1b.0's interfaces, at the end of ariadne_runtime_test.cpp under the Stage 1b banner: - IS-1b SpawnContext.IS01b_InAnIsolatedDocument: IS-1 in an isolated document's group, pumped by plain drain(); the child is in the group, not group 0, and the teardown destroys the group. - AR-1 AriadneFrames.AR01_NoDocumentOptedInStaysOnTheFrameThread: at threads auto with no document opted in, init, ticks, actions, a spawned child and an await all run on the frame thread, and no worker pumps (exec_pool_worker_pumps_total). - AR-2 AriadneFrames.AR02_ThreeDocumentsInGroupZeroPumpOnceAFrame: three Runtimes through drain_begin, exec_pump_frame, drain_end: group 0 is pumped once a frame, and an await whose call ends between two drain_end calls resumes at the next frame's pump. - AR-3 AriadneFrames.AR03_IsolatedDocumentsRunOnWorkers: four isolated documents at 4 workers: the busy residents step on two threads or more, render never begins inside a pump_all, a quick action completes in its drain, and ps, inspect and kill see only the document's own group. - AR-3b AriadneFrames.AR03b_ProvidersPostToTheirGroup: an isolated `any` document's AppRuntime async verb with a done channel, stream open and close and net request (the local HTTP server): each call is tracked by the document's group while in flight, the posts reach a resident in the group, and group 0 has no call, no process and no message. - SP-1 SpawnContext.SP01_AChildOfADeletedChrootWritesTheDetachedNode: a resident's child, spawned after its chroot was deleted, writes the detached node; nothing is made at the old path. - EL-1 AriadneFrames.EL01_IneligibleDocumentsStayInGroupZero: S1-Q6's rules, each ineligible document in group 0 with a reason; eligible ones isolated, affinity host for a declared thread-affine prefix or a host_only native, else any. - FF-3's init half AriadneHazards.FF03_InitLaneRunsProviderCallsOnItsOwnHost: a provider on *ictx.host gives (21 21 6) from init, on an inline host that is not the app's, and init's process is charged both calls (budget-usage). HZ-13 is unchanged. On S1b.0, AR-1 and FF-3 pass; the others fail where the behaviour is not built yet (no isolated documents, the drain split's single pump, spawn_child's re-chroot by path).
Threaded Stage 1b's scenario (S1.md S1.14, td 6.3): `docs` (1, 2, 4, 8) AppRuntimes on one app, each loading an eligible document (a prefix of its own, a strict channels: block; S1-Q6) with ariadne.exec.isolate_documents on, driven a frame at a time by every document's drain_begin(), app.exec_pump_frame(), every document's drain_end(). `t` (0, 1, 2, 4, 8) is the app's exec_pool workers, built before anything builds group 0 or the lock manager (S1-Q1), under unpinned_scope, with the pool scenarios' placement. frame=heavy gives each document's on_tick a 500-iteration loop (about 8000 steps, well over the pool's 100 us inline_below), frame=small one state-incr. No backend and no render: the region is the three calls, ns_per_iter the frame time. Extras: helper_wakes (pool stats), worker_pumps (exec_pool_worker_pumps_total), isolated (documents in a group of their own), pumps, skipped, effective_threads, ticks_per_frame. A point with fewer documents isolated than it has prints a note and passes; a rep fails when a document did not tick. Skipped without yaml-cpp. Smoke: t 0, 2, docs 1, 2, both frames, 4 frames. The runner's gate fails a point that would pass vacuously (GATE_GUARDS): mt.ariadne_docs' rows must have extra.isolated at their docs, since documents left in group 0 never wake a helper. On S1b.0's stubs the gate therefore fails, as it should, until S1.10 isolates the documents.
AR-3b now asserts that group 0's ingress (async_scheduler::ingress_posts_for_test) takes no post and no completion across the isolated document's action, as S1.md's AR-3b row asks, beside the effects it already read. The include block's comments are aligned as clang-format wants.
S1.15's Ariadne lines (S1-Q9, S1.md section 5): - The clang-tsan leg also builds and runs ariadne_runtime_test, with CVC_EXEC_THREADS=4 and --gtest_filter=-AppLockManager.* (the app's pool has workers and its lock manager is shared, which the AppLockManager cases assert is single), and state_lifetime_stress_test (PIN-1). - A leg's matrix may give some of its C++ binaries their own variables and options: `cxx_runs`, one line a binary, `<name>: [VAR=VALUE ...] [--option ...]`, read by run.sh as SAN_CXX_RUNS. A --gtest_filter there gets *Stress* added to its negative patterns; a line naming a binary the leg does not run is an error. Every other binary, and every binary of the gcc legs, runs as before. - SAN_REQUIRED_S1B, appended to every leg's required lines as SAN_REQUIRED_S1A is: the Ariadne cases of section 4 (IS-1b, AR-1, AR-2, AR-3, AR-3b, SP-1, EL-1, FF-3's init lane), HZ-8 (moved from the gcc legs' own lists, so each leg has one copy) and PIN-1's two. AR-3b is thus required in both TSan legs. The lead appends A's, I's and U's unit tests as they merge. - The job's header comment, the matrix comment and docs/TESTING.md's sanitizer section say so. The 180-minute job timeout is unchanged: the gcc tsan leg ran ariadne_runtime_test in 24 s of a 23-minute job on master 7a09366, and the clang leg took 23 minutes on 08fd204 before these two binaries.
S1.9 split AppRuntime's one provider into four by kind, which changed which table wins when two bind one name: a host function lost to (quit), a data-* verb and an async verb it used to override, and an async verb overrode a data-* verb it used to lose to. The provider is now six, registered in the order the one provider bound them at 1407da0, the later winning: the host's sync verbs (host_only), (quit) (host_proxied), the async verbs (any), the data-* verbs (host_proxied), the host's functions (host_only) and its async functions (host_only). So in group 0 every collision resolves as it did; an `any` group installs them in the same order, by kind. Test: AriadneHostVerbs.ANameTwoTablesBindResolvesInTheirOrder pins the winner of each of the 14 pairs of tables that can share a name. It passes with 1407da0's app_runtime.cpp (the one provider) and with this commit; with S1.9's four providers it fails on quit/function, async verb/data verb, async verb/function and data verb/function.
The eligibility scan (S1-Q6) read only the programs the Runtime holds, so a document whose init: alone called oidc-* (or named a '/' channel) was isolated. AppRuntime::load runs init: itself and keeps tests: for run_program; it now hands both to the Runtime with the new Runtime::set_document_programs, before set_root, and the scan reads them with the document's own. Test: AriadneIsolatedDocs.AnInitThatUsesOidcKeepsTheDocumentInGroupZero: a document whose init: calls oidc-sign-in stays in group 0 with the oidc reason, beside the same document with a plain init:, which is isolated. It fails without the hand-over (the document is isolated).
…s init: and tests:
Under CVC_EXEC_FORCE_MOVE a pump_all's caller may not take a group it pumped last, so it hands the call to the workers and waits on the call. A worker that reached the call past its deadline skipped the groups in take_group and notified no one, and the caller waited for ever: exec_pump_frame and an isolated Ariadne document's drain hung when a worker woke late (a loaded machine, TSan). R1b-mid found it; it explains the hang seen once in AriadneIsolatedDocs.ProvidersAreInstalledByTheirKind, and it reproduced under load in a repeat run of the isolation cases. take_group now notifies the call when it skips its groups, and the caller waits no longer than the deadline (in slices of at most a second, so a time_point::max() deadline never reaches wait_until) and then skips them itself. ExecPool.AForceMovedCallEndsAtItsDeadline keeps the pool's one worker in another caller's group past a 50 ms deadline: it failed (the caller still waiting after 10 s) and passes.
…latch (R1b-mid) R1b-mid's fixes for K's Stage 1b cases (S-M1, s-m6, s-m7), in ariadne_runtime_test.cpp's Stage 1b section: - S-M1: AR-3b runs with CVC_EXEC_FORCE_MOVE, so the document's one group, which plain drain() otherwise pumps on the caller every frame, is pumped on workers too. It asserts that workers pumped (exec_pool_worker_pumps_total moves) and that an `any` probe in the action ran on a thread other than the frame thread, which is what the TSan legs need of it. The action now parks with its stream open while a producer thread posts a seq on it (stream::post_seq, found with document_stream); the resident in the group receives it, beside the live and closed posts. IS-1b takes the same knob and asserts a worker pumped its group. - s-m6: AR-3's comment says its render check cannot fail (the test calls render() between pumps) and that the latch is render's debug-build assertion, which Release builds compile out. - s-m7: EL-1 gains a strict document with (msg-send "/x" ...) in a widget's on_click, which the load's lint does not read: it stays in group 0, its reason naming "/x". Each ineligible document's reason is read from the app's log (system.log_output) and must appear there once after three more frames; a log4cplus build skips that check.
…s static / and log, AR-3's latch
…r the host (R1b-mid c-m3) A started net request kept its host's raw address, and settle_started checked cancel_requested() before host.finish(): a check, not a guard. A transport answering on a thread of its own just as an isolated document's group goes (its host dies with the Runtime) could pass the check, then call finish() on the freed host and post to the freed scheduler. async_host::finisher (make_finisher()) holds the host's shared state. Its finish() posts a settled call as finish() does, but under the state's lock and only while the host has not begun to shut down: shutdown() sets `stopped` under that lock, so a post under way ends before the shutdown goes on, and one that comes later touches neither the host nor its scheduler (the shutdown cancelled the call). http_work and uri_fetch_work keep the finisher instead of the host. finish() is unchanged. Test: AsyncCalls.AStartedCallsFinisherPostsOnlyWhileItsHostIsUp. Answered from another thread while the host is up, the call resumes its process; settled and finished from another thread after the host is destroyed, nothing is posted (the scheduler's ingress count does not move). The race itself cannot be made to fail deterministically: the window lies between the transport's cancel_requested() check and its finish, where no code the test controls runs, and the old outcome is a use of a freed host, not an observable result.
CurlWsConnection::send_frame took the easy handle's lock per chunk and continued a partly sent frame after releasing it. libcurl takes a large message in pieces and continues a partly sent frame with the next send's bytes, so two threads sending on one connection (ws-send from two documents pumped on two workers, or a close beside a send) interleaved their messages on the wire. A send mutex is now held across the whole frame; the handle's lock is still taken per chunk, so the reader goes on receiving between them. Test: NetWsClient.TwoThreadsSendingOnOneConnectionSendWholeMessages sends two 4 MiB messages from two threads on one connection while the local server holds off reading, and checks both sends succeed and each message arrives whole. Without the mutex it fails every run (one send fails and the server receives one message).
… and whole WebSocket frames
R1b-mid S-M2. A write under a document emits childChanged on every ancestor, so a render-thread subscriber connected at an ancestor of the document's prefix runs on whichever thread writes. The isolation rules matched a declared prefix only at or under the document's, leaving such a document `any` and its subscriber on workers. A declared prefix at, above or under the document's prefix (or the empty one, the root) now makes its group host. app_runtime.h's declaration comment says so. Test: AriadneIsolatedDocs.AThreadAffinePrefixAboveTheDocumentMakesItHost (probe PC): scene.doc isolated under CVC_EXEC_FORCE_MOVE at 2 workers, "scene" declared and a slot connected on its childChanged; the group is host and the slot runs only on the frame thread. Without the fix: the group is any and the slot runs off the frame thread.
R1b-mid s-m1 (S1-Q8). stop_resident killed the resident and forgot it, so a resident stopped by a reload's set_*_program or by a mount reconcile stayed in group 0 as a killed record for the app's life: neither the sweep nor teardown knew its pid. It is now killed and reaped at once (its forks keep their own context). ariadne.h's set_tick_program comment says so. Test: AriadneHazards.AResidentAReloadStopsIsReaped (probe PB): a tick resident, a second set_tick_program, then teardown; group 0 holds only the new resident before teardown and nothing after. Without the fix: the stopped resident's killed record is left (2 processes, then 1).
9b43e8a's edit to connect_node's comment left one line over the column limit. Comment reflow only.
register_net_intrinsics makes the clock and its host_proxied provider hands it to each program's (open-url), so every program the app builds shares the limit and no process-wide object holds it. The allowlist drops the static's line.
ci.yml's sanitizer test list keeps this branch's stream_test, net_ws_client_test and ariadne_host_test and master's contour_stack_test. The allowlist ratchet (#1152) passes: against master the list only loses the open-url clock's line.
…erf/threaded-s1b #925 starts ws-open's connect and ws-recv's wait where the transport does not block (the browser without threads), and their callbacks settle the call. Its start paths kept the async_host by reference and posted through it; here they take the host's finisher (host.make_finisher()) and settle_started through it, as http_work and uri_fetch_work do: the callbacks answer later, and an isolated document's group's host may be gone by then. - net_intrinsics.cpp: the conflict kept this branch's providers by kind; have_ws takes master's NetAccess::ws. The any provider's comment says a host's own WebSocket transport must be as thread-safe as the compiled backend. - ariadne_runtime_test: both sides' new L4 cases are kept, plus AStartedWebSocketCallKeepsTheHostItStartedOn, the WebSocket twin of AStartedRequestKeepsTheHostItStartedOn.
async.pool_aging's time per call is mostly the OS waking the floating kernel thread, so the core it lands on sets that time more than either executor does. Its records now carry the share of calls whose kernel ended on a CPU of the fastest efficiency class (P-cores on a hybrid part), over the first and last 10 % of calls and over all of them: extra.first_fast_cpu_share, last_fast_cpu_share and fast_cpu_share (-1 off Windows or on a uniform part). On a Core Ultra 9 185H, over 184 stretches of 10 % of calls, those with at least 99 % of kernels on P-cores took a median 9.1 us a call and those with under half 22.5 us (Pearson r -0.55). This is what made the threaded Stage 1b A/B's pool_aging points 45-55 % noisy: with the same frozen binaries interleaved every few seconds, base 8cba3b1 and candidate b4af08c differ by -6.4 % to +3.4 % per round, and by -2.2 % to +2.2 % with the kernels kept on one P-core.
The two conflicts were include lines. ariadne.cpp keeps this branch's requires.h and stream_intrinsics.h and adds #1180's rich_text.h. ariadne_runtime_test.cpp keeps stream/stream.h and adds rich_text.h. #1180's rich text reads its runs and fires on_link through the Runtime's existing reactive evaluation and handler queue, so it follows this branch's group routing as it is; its last-good runs are a per-Runtime map.
#1203 (no singletons) moved the URI registry, the HTTP client and options provider, the HTTP cache's in-flight table, the net and OIDC hosts, the WebSocket table and open-url's clock onto each app. This branch had changed the same code for threads. The merge keeps both: - uri.h/uri.cpp: register_uri_handler and resolve take the app (#1203) and keep this branch's UriCancelled and UriLocalHandler; the http(s) handlers and the HTTP cache pass the request's cancel predicate through to the app's client. - net_intrinsics.cpp: the providers stay by kind with each call on the calling program's host (ictx.host) and its finisher. The requests, fetch and WebSocket verbs take the app, the app's WsTable and its OpenUrlLimit (both app slots, got once at registration). open-url stays in its host_proxied provider, on the app's OpenUrlLimit instead of a clock of the provider's own. - oidc_host.cpp: the refresh sends through the app's client with the asker's cancel predicate. - ariadne.cpp: the Runtime's owner id is counted per app (#1203); has_snapshot asks the app's widget registry. - allowlist.txt: master's (76 lines); the one line this branch removed is gone there too. This branch's tests move onto the per-app APIs: the removed NetIntrinsicsGuard, L4Guard and NetHostGuard go, set_http_client and send take the app, live_groups takes the app by reference, and the worker pump counts come from the pool's stats (pool_stats::worker_pumps) where the process-wide exec_pool_worker_pumps_total() was, in the tests, mt.ariadne_docs and the docs. Also fixed: #1180's three rich-text tests called load_string without the app #1203 added.
The code merged without conflicts. Stage S's step_run, set_slice and process_table's begin_run/preempted are as on master. This branch's one change on that path is the ingress post counter (ingress_posts_for_test), taken in post_message and post_async_completion under the ingress lock, beside the ingress_pending_ flag that ends a run. A post from another thread still ends a run within one step. Two doc conflicts. STATE_EXEC_THREADED.md takes master's Stage S section. STATE_EXEC_BENCH.md takes master's Stage S gates, without its one-line placeholder for S1b, whose gates this branch describes just above.
It runs three times per pool_aging record, after the run, so it needs no function-local cache.
…#1222-#1225, #1229) Master's #1190 (file-pick and http-upload) was written for a single async host; this branch runs an isolated document's programs on its own group's host, on a pool worker in an `any` group. - net_intrinsics.cpp: StartedRequest takes master's deliver()/on_outcome, settling through the host's finisher. http-upload is its own provider, `any` as the requests are: it parks on the calling program's host (ictx.host), takes its progress path from ictx.root_path (no tree walk on a worker), and a started upload (a browser page) keeps the host's finisher, not the host. - ariadne.cpp: file-pick, file-info and file-forget bind into the program's env as they are, in every group (install_backend_verbs), not through the backend verbs' host_proxied wrapper, which cannot park an async verb. file-pick parks on the program's own host, claims the Runtime's picker hub under its lock where it is called, and opens the picker on the host thread (exec_pool::run_on_host; inline when called there). Its answer goes through the host's finisher, as the host may be gone by then. - ci.yml: the sanitizer list keeps this branch's tests and master's point_classes_test. - STATE_EXEC_THREADED.md: rows for http-upload, the file verbs, and the contours and point-classes providers. The last two are registered without a kind, so they are host_only, and an isolated document in an app that installs them goes to a host-affinity group. - New test: AriadneIsolatedDocs.FilePickOpensItsPickerOnTheFramesThread.
Master's #1217 keeps nothing per thread in state_exec: a native's context (call_args::context()) carries its group, registry and stream, async_host::call and begin_external take it, and the pool drops in_pump_all() and the one-argument run_on_host. - async_host.h: begin_external takes the context, as on master, and keeps this branch's note that a call is finished through the host it was made on. - script_engine.cpp: the sliced form finds the calling program's group from the call's context (exec_group::current(ctx)), else group 0, and reads its data step from the context. - ariadne.cpp: file-pick opens its picker through run_on_host for the group its verbs were bound for (the env's, as its host is), and inline in group 0 and the init lane. - exec_pool: in_pump_all() is back, for the host-thread calls' debug assertion and ScriptLane::run's refusal, read from the pool's calls (their callers' and pumpers' thread ids) under its mutex rather than from thread-locals. - ariadne_runtime_test: the init lane's cycles test no longer compares against the calling thread's own registry, which master removed; it is AriadneInit.RunsAScriptThatLeavesCycles. - ci.yml: the sanitizer's required list names the test by its new name. - STATE_EXEC_THREADED.md: B29-B31 and the file-pick and sliced-call notes name the context-based calls.
transfix
marked this pull request as ready for review
November 15, 2026 07:53
- app_runtime.cpp: the constructor hands the scene its repeat: count function (#1230), then takes the verb table's lock as before. - e2ee_intrinsics.cpp (#1191): the e2ee-* provider registers its async functions on the calling program's host (*ictx.host, else the app's), as every provider on this branch does (B30), so an isolated document's e2ee-backup and e2ee-restore park on its own group. - STATE_EXEC_THREADED.md: the e2ee provider in the provider table and the file list.
- stream_intrinsics.cpp: the stream provider stays `any`, and #1236's raster verbs are a provider of their own, registered `host_proxied`: they are synchronous, raster-open and raster-publish write the raster's mirrors into the state tree raw (write_node), and one thread paints and publishes a raster, so in an `any` group they run on the host thread. Registered host_only (the default) they would have put every isolated document of an app with the stream verbs in a host-affinity group. - STATE_EXEC_THREADED.md: the raster verbs and #1171's skeleton provider in the provider table, and the file list.
async.pool_aging's time per call moves far more than the driver's cost does. A call is the driver's turnaround (the previous kernel's end to this call being made), which is the handoff (to the first step slice after that end: the completion posted, seen, drained and woken) plus the driver's work (the steps up to the call), then the kernel thread's wake (the call being made to its kernel starting). The kernel thread spins a few us in its wait before it blocks. On a Core Ultra 9 185H with the kernels on one P-core, a call made within about 5.2 us of the previous kernel's end waits about 1 us for its kernel, one made later about 7 us, and the driver's turnaround is about 5.1-5.3 us, right at that edge. The two feed each other: with 25 ns more driver work per call (a calibrated busy loop before the call, interleaved, quiet, kernels on CPU 12), driver work rose about 250 ns, the share of slow wakes 0.1-0.2 and the time per call 11-26 %; with 100 ns, about 400 ns, 0.1-0.4 and 15-31 %. Over a run, driver work grows 13-19 % and slow wakes go from under 10 % to about half, which is what makes late calls 40-50 % slower than early ones. It is also why threaded Stage 1a's pool_aging points were +6.5 % to +15.7 % slower (15-18 of 20 quiet rounds) from a step cost of at most about 1 % in inflight_tax. The records now carry extra.turnaround_ns, handoff_ns, driver_work_ns and wake_ns (each the mean of its middle 90 %, over all calls), first_ and last_ forms of driver_work_ns and turnaround_ns, and slow_wake_share (wakes over 2 us) with its first_ and last_ forms. drive() stamps each step slice's start when drive_cfg::slice_ns is set. The counters themselves leave the time per call level (-7.5 % to +2.2 % against the build before them, mixed signs).
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.
async.pool_aging's time per call moves far more than the executor's cost does. This makes its records say why. Bench and docs only (state_exec_bench.cpp,docs/STATE_EXEC_BENCH.md); no library code changes, no new statics orthread_locals.What the records gain
extra.first_fast_cpu_share,last_fast_cpu_share,fast_cpu_share. These are the share of calls whose kernel ended on a CPU of the fastest efficiency class (P-cores on a hybrid part), over the first 10 %, the last 10 % and all calls. -1 off Windows or on a uniform part.turnaround_nsruns from the previous kernel's end to this call being made. It is the sum of:handoff_ns: to the first step slice after that end (the completion posted, seen, drained and woken).driver_work_ns: from that slice's start to the call (the steps).wake_nsruns from the call being made to its kernel starting.slow_wake_shareis the share of wakes over 2 us.first_andlast_forms cover the first and last 10 % of calls.drive()stamps each step slice's start whendrive_cfg::slice_nsis set.Why
Placement. The kernel threads float, and on a Core Ultra 9 185H stretches of calls with at least 99 % of kernels on P-cores took a median 9.1 us a call, under half on them 22.5 us (184 stretches, r -0.55).
A spin-then-block threshold.
So neither the time per call nor any leg is linear in the executor's cost. Executors compare on the step scenarios (
inflight_tax,sched.single). Apool_agingchange should be read againstslow_wake_share.Two A/Bs this explains:
inflight_taxc=0/1, 12 quiet rounds: -0.8 % to +1.1 %), about 25 ns a call, amplified by the threshold above. S1a's per-call code changes on this path are a few ns: one more serial compare per await, a null registry check per scheduler entry.Test
state_exec_bench --scenario async.pool_agingprints the new fields. In the validation above,driver_work_nsrose in 10 of 10 rounds at every point for both delays.