Repository navigation
Ariadne: the read lane keeps its results until what they read is written - #1084
Merged
Merged
Conversation
…arning On the live nicotina page (arigl-web, real tx.wtf) a 10-post feed decoding pictures in wasm spends the 30 ms read-lane budget on its first frames, and each expression it skipped became "ari: reactive expr ... skipped - per-frame budget exhausted" through warn_once, which the page's ariadneWarning shows the user. A skip is not the document's fault. - Every read-lane path takes a skip the same way: last frame's value, else the fail-safe one, and no warning. predicate (visible_when / enabled_when / disabled_when): last answer, else hidden / disabled (one skipped before it ever ran warned). eval_text (computed binds, src): last text, else empty. eval_text_or_literal (tooltip): last text, else empty, not the expression's own source. eval_options: last list, else empty. eval_count (repeat:): last count, else 0. - Real errors (parse, runtime, unbound, step / time cap) still warn once. - Runtime::reactive_skip_count() counts the skips, for a host that logs them. - The engine's String/StringList/Int outcomes say skipped, as Outcome did. Docs: ARIADNE.md section 2.1; the set_reactive_frame_budget / take_reactive_warnings comments. Test: ariadne_media_test's AriadneReactiveBudget.ASkipIsNeverAWarning.
Every visible_when, enabled_when / disabled_when, computed bind / text, tooltip, options and
repeat count ran again each frame (only the parse was cached). A nicotina card has about 21, so a
ten-card feed ran ~210 a frame, nearly all giving last frame's answer, and on single-threaded
arigl-web, sharing the thread with picture and video decode, they spent the 30 ms budget.
- ReactiveEngine keeps each result per scope and expression text ({i} rows apart), with the state
paths its readers named (state-get, state-exists, state-children, state-data-get, state-json,
wrapped to note them) and the (has? ...) answers it got (each name asked once a frame).
- It is reused, not run, until a write lands on a path it read, an ancestor or a descendant of
one, or an asked name answers otherwise. Writes come from the tree root's childChanged (value,
data, touch, links, removeChild, the expiry sweep), on any thread: the slot appends the path to
a mutex-held log, folded into per-path generations by the frame thread before each lookup.
- Never kept: a result that read (time-now), an expiry, or a node through a link; an expression
naming a reader that could not be wrapped; errors, timeouts, skips.
- A kept result is not run, so the frame budget never skips it.
- Unused for 300 frames: dropped. Runtime::reactive_eval_count() counts what ran.
Docs: ARIADNE.md section 2.1.
Tests: ariadne_media_test's AriadneReactiveCache (an idle frame runs nothing; a write reruns what
read it; the clock and a link stay live; a repeat's rows are kept apart; a kept result is never
skipped; a changed has? answer reruns it).
# Conflicts: # docs/ARIADNE.md # inc/cvc/ariadne/ariadne.h # src/cvc/ariadne/ariadne.cpp # src/cvc/tests/ariadne_media_test.cpp
transfix
enabled auto-merge (squash)
November 9, 2026 20:01
transfix
added a commit
that referenced
this pull request
Nov 9, 2026
…andles (#1099) One conflict, in ariadne.cpp's includes: both sides kept. Master's cache notes state writes under a lock on the writer's thread, so writes from an isolated document's group on a pool thread invalidate a kept result like any other.
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.
The read lane now keeps its results: a frame re-runs only the expressions whose inputs changed. Stacked on #1082 (the same eval paths, and the counter beside
reactive_skip_count); review the last commit.The problem. Until now every
visible_when,enabled_when/disabled_when, computedbind:/ text,tooltip,optionsandrepeat:count ran again every frame; only the parse was cached. A nicotina card has about 21 of them. That makes a ten-card feed about 210 runs a frame (around 12,600 a second at 60 fps), nearly all giving last frame's answer. On single-threaded arigl-web, which shares the thread with picture and video decode, they spent the 30 ms budget.What is kept.
ReactiveEnginekeeps each result per scope and per expression text (so each{i}row is its own), along with what the run read:state-get,state-exists,state-children,state-data-getandstate-jsonare wrapped to note them, as absolute normalized paths; no path means the whole scope;(has? …)answers it got.has?is answered once a frame per name and noted.When a kept result is used. A result is reused, not run, until one of these happens:
Writes are seen through the state tree root's
childChanged, whichvalue,data,touch, link changes,removeChildand the expiry sweep all fire, from any thread. Its slot only appends the path to a mutex-held log, capped at 4096 a frame (past that, everything is stale). The frame thread folds the log into per-path generations before each lookup: a written node's own, and the newest write at or under each path. A frame with no writes costs one atomic load per lookup.What is never kept:
(time-now)or an expiry (state-is-expired,state-has-expiry);The budget (L24). A kept result isn't run, so it never counts against the 30 ms and is never skipped.
Housekeeping:
API:
Runtime::reactive_eval_count(), the expressions that ran.Cost: while a Runtime has a read lane, every state write in the app builds its path once for the root's slot. Without a slot it builds none.
Not done (the optional step in the request): re-running stale entries on the app scheduler while the frame draws the old value. With nicotina's controller precomputing card decisions, an idle feed now runs nothing, and a changed post runs only its own card's expressions.
Docs: ARIADNE.md §2.1.
Tests (
ariadne_media_test,AriadneReactiveCache):AFrameThatWroteNothingRunsNothingAWriteRerunsWhatReadItAndNothingElse: the path, a descendant, an ancestor, an unrelated path, a same-value write, another thread's write.TheClockAndALinkStayLiveARepeatsRowsAreKeptApartAKeptResultIsNeverSkippedAChangedHasAnswerRerunsItLocally on Windows (FTXUI on), every Ariadne suite and the
cvcgl_imgui_*/cvcgl_ari*tests pass.