Repository navigation
Ariadne async execution semantics: scheduler_base + async_scheduler parity (1/5) - #435
Merged
Merged
Conversation
One long-lived async_stackless_evaluator + async_scheduler for the whole host, NOT one per .ari document. All program lanes (init:/action/on:tick·on:key residents/spawned) schedule on one cooperative timeline; isolation is kept by namespacing on that shared scheduler — per-Runtime owner scope (process-group tag), per-process chroot to the document prefix, and a per-document child env over a shared immutable base — with Runtime teardown reaping its process group. The reactive READ lane stays a separate per-Runtime synchronous stackless_evaluator and is never placed on the shared scheduler (predicates must return instantly). Message delivery/wake must be MPSC-safe so a worker thread (e.g. compute-pool nav step) can resolve an (await ...)/(msg-recv ...) by msg-send from off the UI thread. Foundation for the P2 action lane + P2-prereq state_exec parity work.
…nterface
P2-prereq for the async execution semantics (CVCGL-UI-DSL §4.7/§8): the DSL
intrinsics (spawn/sleep/msg-send/msg-recv/self/ps/kill/pause/resume + the
state-watch registry) reached the scheduler through intrinsics_context.sched,
hard-typed to the synchronous `scheduler`. That blocked driving them from the
coroutine async_scheduler. Extract scheduler_base: an abstract interface of
exactly the ~18 methods intrinsics.cpp invokes, plus the shared vocabulary
structs (scheduling_policy/execute_options/process_info/scheduler_stats moved
out of scheduler.h). `scheduler` now derives from it; intrinsics_context.sched
is re-typed to scheduler_base* (the three production assignment sites upcast
implicitly — no change). The driver surface (step/run/stop/has_runnable/
load_settings) stays off the base: the host that pumps a scheduler holds the
concrete type.
Pure refactor, behavior-identical. Verified: core cvc lib + pycvc_exec build
clean; state_exec_{scheduler,intrinsics,multiprocess,advanced_integration,
integration,async} + ariadne_runtime = 511 tests PASS.
Next: async_scheduler derives from scheduler_base (implement its missing
sleep/receive_message/deliver_to_receivers/pop_pending_message/current_pid/
current_process + wake_sleeping + deadline guard).
…ing parity)
Commit 2 of the async execution semantics. async_scheduler now derives from
scheduler_base, so the DSL intrinsics drive it identically to the sync
scheduler. Ported the methods it lacked (bodies mirror scheduler.cpp):
sleep, receive_message, deliver_to_receivers, pop_pending_message,
pending_message_count (+ total_pending_messages), plus the pending_messages_
FIFO and current_pid_/current_proc_ tracking with current_pid()/current_process().
Wired the two gaps its step loop had vs the sync scheduler:
- wake_sleeping_processes() at the top of step() (a slept/msg-waiting process
could never wake before);
- the per-step eval_deadline_guard in execute_process_step (an uncapped nested
eval / long builtin inside one step is now bounded by the process's remaining
time budget).
Also fixed a latent bug in async execute_process_step: its completion branch
unconditionally reset status to `ready`, clobbering the `waiting` that
sleep/msg-recv set — now guarded with `else if (status == running)`, matching sync.
Still drives a synchronous stackless_evaluator inner (Commit 3 switches it to
async_stackless_evaluator). Verified: +7 tests (AsyncSchedulerTest x4 at the
scheduler API — spawn/run, recv-suspends+deliver-wakes, queue+pop, sleep→wake;
AsyncSchedulerIntrinsicsTest x3 through the intrinsic layer with
ictx.sched=&async_scheduler). Full state_exec + ariadne suite: 518 tests PASS.
…eduled evaluator) Commit 3 of the async execution semantics. Per roadmap §8.12 the scheduled evaluator IS async_stackless_evaluator; async_scheduler's inner evaluator_ is now that type (was a plain stackless_evaluator). create_state/ctor are unchanged (both forward to the inner stackless evaluator); execute_process_step drives one evaluator step to completion at the leaf via `evaluator_.step(state).sync_wait()`, which consumes the coroutine's per-step suspend_point. Deliberately NOT propagating that suspend_point up into step()/run() as a true co_await chain: it only buys intra-run interleaving when a coroutine executor drives the scheduler, which neither sync_step/sync_run nor the planned per-frame pump do — and a multi-level co_await that suspends across sync_wait is not robust here (an earlier attempt mis-returned the process result). DSL-level await/parking across frames is delivered by the scheduler's waiting-status mechanism (sleep/msg-recv wake), not the C++ suspend_point. When a real async executor is added, only execute_process_step's drive changes — not the evaluator type. Verified: 518 state_exec + ariadne tests PASS (incl. the AsyncScheduler* suites now running through async_stackless_evaluator).
Owner
Author
|
Commit 3 landed ( |
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.
Ariadne async execution semantics — the single app-wide scheduler +
awaitFoundational runtime work so Ariadne's program lanes (
init:/ actionon:/ futureon:tick·on:keyresidents / spawned) run cooperatively on one long-livedasync_stackless_evaluator+ scheduler, with(await …)/(sleep …)/(msg-recv …)suspending across frames instead of blocking the UI thread. Closes the P2 §4.7
(long-lived cross-frame scheduler) + P2-prereq (
state_execparity) gaps from the roadmap.Design decision (recorded in
CVCGL-UI-DSL-ROADMAP.md§4.7)One app-wide scheduler for the whole host, namespaced per document — not one per
.ari.All program lanes share one cooperative timeline (cross-document
spawn/msg, one per-frametime budget); isolation is kept by a per-
Runtimeowner scope (process-group tag),per-process chroot to the doc prefix, and a per-document child env over a shared
immutable base, with
Runtimeteardown reaping its process group. The reactive READ lanestays a separate per-
Runtimesynchronousstackless_evaluator(predicates must returninstantly — never parked). Message delivery/wake must be MPSC-safe so a worker thread
(e.g. a nav step on
app.computePool()) can resolve an(await …)/(msg-recv …).This PR (Commits 1–2 of 5 — foundation)
scheduler_base— extract the intrinsic-facing scheduler interface (the ~18 methodsintrinsics.cppinvokes) + the shared vocabulary structs.schedulerderives;intrinsics_context.schedre-typed toscheduler_base*(the 3 production assignment sitesupcast implicitly). Pure refactor, behavior-identical.
async_schedulerimplementsscheduler_base— so the DSL intrinsics drive the asyncscheduler identically to the sync one. Ports the methods it lacked (sleep / receive_message /
deliver_to_receivers / pop_pending_message / pending_message_count +
pending_messages_FIFOcurrent_pid_/current_proc_); wireswake_sleeping_processes()intostep()and theper-step
eval_deadline_guard; fixes a latent completion-branch bug that clobbered thewaitingstatus set by sleep/msg-recv.Follow-ups (same branch, incoming)
async_scheduler's inner evaluator toasync_stackless_evaluator(drive viatask<>).(await expr)on the scheduled path.cvc::app, per-framepump, per-
Runtimeowner scopes, action-lane submit-and-return.Testing
build-ari: corecvclib +pycvc_execbuild clean; 518 tests pass acrossstate_exec_{scheduler,intrinsics,multiprocess,advanced_integration,integration,async}+ariadne_runtime, including +7 newAsyncScheduler[Intrinsics]Testcases proving theasync scheduler drives spawn/sleep/msg-recv through the intrinsic layer, sleep→wake,
deliver-wakes-receiver, and the message queue.