Repository navigation
Ariadne: a resident that stops is restarted; a setting for its step cap - #917
Merged
Merged
Conversation
- (quit [code]): AppRuntime::register_quit() binds `on: quit` and the verb; the first close request's code is exit_code(). ari run/snapshot/check and arigl (window and --terminal) exit with it; snapshot stops on the frame the document quit. - (assert cond [message [data]]): a builtin raising AssertionError (a new class under Exception), "assertion failed[: message]"; its traceback ends at the form. - tests: block (name -> program) captured by the loader; Runtime::run_program runs a program on the action lane and reports how it ended to a callback. - ari test [--tap] [--timeout S] [--frames N] doc.ari...: each document headless until it quits, its tests have run, N frames, or the timeout. Fails on a non-zero quit, an uncaught error, a failed or warning load, a failed test, or a timeout. One line per document with what failed and in which program; TAP with --tap; exit 1 on failure. Network flags and settling as snapshot's. - Action failure warnings name their program; resident ones their lane. - Docs: ARIADNE.md §13, the exceptions table, the developer guide.
…s modules (#894) - functions: (top level): a program of (defun ...) forms that every program in the document's scope can call (init:, on:, residents, key bindings, tests:); anything else is skipped with a warning. import: merges a library's functions. - load: functions: [names] | name | "*": grants the parent's functions to the module, each with the functions it calls; a module gets none otherwise, and its own functions: stay inside it. Code, not authority: a granted function runs chrooted to the module. - Mechanism: Widget::functions (FunctionScope) on the root and every mount wrapper; the runtime keeps a function-scope stack beside the mount scopes and runs the scope's prelude ahead of each program (actions, residents, run_program, init:, mount init:). - The free-head preflight is scope-aware and scans function bodies and mount init:. - Docs: ARIADNE.md §6.6.
- Loader: expand_load captures the fragment's on_tick: onto the mount wrapper (Widget::tick_script), as it does init:. A fragment's on_key:, on_pointer: and on_signal: now load with a warning instead of being dropped silently: input and signals stay the outermost document's (docs/ARIADNE.md §6.3). - Runtime: one tick resident per mount sub-prefix, owner-tagged, chrooted there with the mount's FunctionScope prelude, on <owner>#tick@<sub-prefix>, woken each drain by post_tick. Started on the mount's first frame, after its init:. A reconcile keeps it when the new tree has the same mount and program, and stops it otherwise. A repeated mount's instance stops when its outermost repeat: count drops below it. - A failing module tick is reported as on_tick: of mount '<sub-prefix>'. The preflight and the channel lint scan a mount's on_tick:. - Tests: AriadneModuleTick.* (ariadne_host_test), AriTest.AModulesOnTickRuns. - Docs: ARIADNE.md §2.3, §2.4, §6.3, §7.4.
…-tick The locks spawn context (#865) makes resident contexts shared and built by make_action_context: a mount's tick resident is made the same way, chrooted to its sub-prefix.
…illing stepped_solve::impl did f.assign(nv, f[0]): the value is a reference into f, and libc++'s assign frees the old buffer before filling the new one, so on macOS every entry was read from freed memory (Fem.SteppedPoissonMatchesTheOneShotSolve, rel diff 6.7e268 in the macOS recipe lanes). libstdc++ and MSVC copy the value first, so Linux and Windows passed.
Takes #903's fix for the stepped Poisson solve in place of the same fix made here.
- A tick, key, pointer or signal resident, or a module's tick, that is killed (its per-step cap, a syntax error read inside it) or fails (an exception it didn't catch) is reported once per message as before, reaped, and started again on a later drain: at once the first time, then 1, 2, 4 ... up to 64 drains later while it keeps stopping within 100 drains of starting. After 8 such stops in a row it is given up with a warning, until its program is set again. A module's tick restarts whether or not the mount is drawn. A signal arriving during the delay starts its handler at once. Before, a stopped resident stayed dead: a module's on_tick request loop sat on "loading..." for good, and a dead on_signal swallowed every Ctrl-C. - Residents share one Resident record (context, pid, restart state) instead of parallel context and pid fields. - The per-step cap is the tree setting ariadne.limits.resident_max_step_time (0 = none), default 0.05 s, 0.25 s in wasm, which has no thread CPU clock, so a step that checks often on a loaded machine is charged for its waits. - Tests: AriadneResidents.* (a failed tick restarts, a module tick killed by its cap restarts, one that always fails is given up and a reload starts it afresh). - Docs: ARIADNE.md §2.3, §2.4.
…at/ari-resident-restart
cypkg's browser test (single-threaded ari.html, load 10-33): with the 0.05 s cap one run of nine lost a module's tick; with 2 s none of nine did. A runaway step in a tab then freezes it for at most a second before the resident is killed and restarted.
The PRs below this one landed on master squashed, so this branch's own change is applied to master unchanged.
transfix
enabled auto-merge (squash)
October 31, 2026 07:37
…estart # Conflicts: # src/cvc/tests/ariadne_host_test.cpp
transfix
added a commit
that referenced
this pull request
Oct 31, 2026
… file #917 adds its resident-restart tests where these were, after the module-tick tests; at the end they no longer conflict with it, whichever lands first.
transfix
added a commit
that referenced
this pull request
Oct 31, 2026
transfix
added a commit
that referenced
this pull request
Oct 31, 2026
…ning process (#927) * state_exec: the resource intrinsics and state-watch speak for the running process A host that runs programs on a shared scheduler gives each intrinsics context a placeholder process and no pid: Ariadne's action and resident lanes do. time-elapsed, time-limit, step-count, memory-limit and the message counters read that placeholder, so they reported 0 there, and a loop bounded by (time-elapsed) never ended. state-watch registered its handler for pid 0, which the scheduler ignored, so a watch set from an action or a resident never fired. They now use the process the scheduler is stepping (running_process / running_pid), as self-pid, budget-usage, msg-send and await already did, and the context's own only with no step running. Tests (AriadneResourceIntrinsics.*): a resident's clock-bounded loop ends by the clock with a non-zero step count, an action sees its time limit, and a resident's watch fires; each fails on master. Docs: the developer guide. * ariadne_host_test: the resource-intrinsics tests go at the end of the file #917 adds its resident-restart tests where these were, after the module-tick tests; at the end they no longer conflict with it, whichever lands first. --------- Co-authored-by: nicotina-ci <[email protected]>
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.
A tick, input or signal resident that is killed or fails is now started again, instead of staying dead for the rest of the document. A
load:ed module'son_tick:(#904) is a resident too, so a module's request loop can no longer get stuck.Stacked on #904 (
feat/ari-module-on-tick). Rebase onto master once #904 merges.Why
cypkg's browser test sees one
load:ed module'son_tick:request never resolve, in about 1 run of 3 on a heavily loaded machine. The module stays on "loading..." while the rest of the page runs. What was checked in the code:Never restarted. Once a resident was killed or failed, nothing started it again:
ensure_residentreturned early because the pid slot was still set;ensure_mount_tickreturned early once the channel was set;post_tickkept posting to the dead channel.The same held for the document's own residents. A dead
on_signal:also swallowed every Ctrl-C, becausepost_signalsaw a pid and reported the signal handled.The step cap. The 50 ms per-step cap is a
se::time_budget. Its first half is charged on the steady clock. Its second half is charged on thread CPU time, with each gap between checks counted up to 1/16 of that half. So on native builds a descheduled step must still run 25 ms itself before it is killed. Single-threaded wasm has no thread CPU clock (thread_cpu_secondsis the steady clock there), so a step that checks often on a loaded box is charged for its waits too.What changes
retire_if_stopped, in the per-drain sweep). A killed or failed resident is reported once per message, as before, then reaped and scheduled to start again on a later drain:on_tick,on_key,on_pointer,on_signaland each module'son_tick. A module's tick restarts from the drain, whether or not the mount is drawn.MountTickshare oneResidentrecord (context, pid, restart state), instead of parallel context and pid fields.ariadne.limits.resident_max_step_time, in seconds, with0meaning no cap. It is read as each resident starts. The default is 0.05 s natively and 1 s in wasm. Scheduler time semantics are unchanged.cypkg's step-cap experiment (single-threaded ari.html, cy-pca/cypkg@dcc24cf, master + state_exec: json-parse, json-encode and state-set-tree, so documents can read REST replies #883 Ariadne: (quit code), assert and
ari test#896 Ariadne: functions: shared with a document's programs and granted to its modules #900 Ariadne: a load:ed module's on_tick: runs at its mount #904 Ariadne L4: requests in single-threaded wasm don't stall the frame loop #914) supports the wasm default, but only suggestively:A restart alone doesn't save a module that marked its request in flight before it was killed. That's why the wasm cap is raised as well.
Not done
take_warnings(), whichari runprints after the screen exits. A host hook for that is a follow-up.arifrom master + state_exec: json-parse, json-encode and state-set-tree, so documents can read REST replies #883 Ariadne: (quit code), assert andari test#896 Ariadne: functions: shared with a document's programs and granted to its modules #900 Ariadne: a load:ed module's on_tick: runs at its mount #904 Ariadne L4: requests in single-threaded wasm don't stall the frame loop #914 + this PR at 3753185.Tests
ariadne_host_testAriadneResidents.*:resident_max_step_timeis restarted, and runs once the cap is lifted;ari_test_command_test8, ftxui 66, loader 207,ari_net8.