Repository navigation
state_exec: a run's step budget counts what each pick charged (G1, fifth part) - #1117
Merged
Merged
Conversation
…fth part) async_scheduler's run loop counted a pick as one step against max_steps, whatever the pick's evaluator step charged on top of itself through evaluation_stats::add_steps. A script engine's slice charges its work that way: Ariadne's ScriptSlice::charge, a wasm guest's fuel at 64 steps a slice. So a slice cost the drain's 200,000-step pump budget one step, and a guest could stretch a drain to its 0.1 s backstop: 4,545 slices of 10,000 steps in one drain, where the budget allows about twenty. Now execute_process_step records how much the step moved the process's step count (its own step, plus what it added), read before a finished process lets go of its state. The run loop counts that, at least one, against max_steps, and sync_run_steps() returns the same count. An iteration that picks nothing still counts one. A plain program charges one step a pick, so nothing else changes; an inline async call's run time (3.8) now counts too. Tests: AsyncSchedulerTest.ARunsStepBudgetCountsWhatAStepCharged and ScriptEngineTest.ADrainCountsWhatTheSlicesCharge; both fail on the old count (1,000 calls in a 5,000-step run; 4,545 slices in a drain). Docs: async_scheduler.h, the developer guide's pump notes, and the scripting hosts roadmap (8.3, 8.5, the G1 row).
transfix
enabled auto-merge (squash)
November 10, 2026 02:23
transfix
added a commit
that referenced
this pull request
Nov 10, 2026
Conflicts in script_engine.h and script_engine.cpp, both kept: the sliced form is bound where the program's host parks (this branch) and takes its activation's lock around the job (master's #1126). The lock is a with-lock key on the app's one lock manager, which every group shares (4.19), so it excludes across group 0 and isolated groups alike; STATE_EXEC_THREADED.md says so. #1117's run loop counts what each pick charged, so a group's pump budget counts a slice's steps as group 0's does.
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.
G1, fifth part: the drain's pump budget now counts the steps guest slices charge, not one step per pick. Before, a guest could stretch a drain to its 0.1 s backstop (roadmap §8.5, "Slices").
The bug
async_scheduler's run loop counted each pick as one step againstmax_steps, however much that pick's evaluator step charged on top of itself throughevaluation_stats::add_steps. Script engines charge their work that way: Ariadne'sScriptSlice::charge, and a wasm guest's fuel at 64 steps a slice. So:The fix
execute_process_steprecords how far its step moved the process's step count (get_step_count()): the step itself, plus anything it added.max_steps, andsync_run_steps()returns the same count.A plain program charges one step a pick, so its count is unchanged. Two kinds of work done inside a step now count:
Every pump of an async scheduler counts this way: the Ariadne drain,
exec_group's pump and pycvc'sExec. The sync scheduler is unchanged.Docs
async_scheduler.h'srun/sync_run_steps.Tests
Local, Windows static Release tree:
AsyncSchedulerTest.ARunsStepBudgetCountsWhatAStepCharged: a native charging 1,000 steps a call uses up a 5,000-step run in about five calls.ScriptEngineTest.ADrainCountsWhatTheSlicesCharge: about twenty 10,000-step slices a drain, and as many in the next.ariadne_script_engine_test23/23 andariadne_wasm_test18/18, three runs each;state_exec_async_test107/107 andstate_exec_groups_test28/28;ariadne_runtime_test262/262 andstate_exec_exceptions_test25/25;arix_wasm_blockandari_wasm_needs_arixctests.Left for G1
RecursionErrorfor indirect re-entry.state_exec.policy.