Repository navigation
Structured concurrency, and release 0.7.0 - #75
Merged
Merged
Conversation
…re_count(), fix-it R_PARALLEL_LIMIT parallel_map's worker limit defaults to 64 on every machine and [runtime] max_parallelism can raise it to 1024; going over names the guion.toml line. std:process gains core_count() (Process function code 3, artifact format 76). The HTTP client's thread pool follows the limit up to 64 instead of 8. Also lays the deadline plumbing the next step uses: a policy deadline that caps every blocking host call (http, process, socket) and stops the VM. The self-hosted compiler stays frozen at format 74; only its builtin catalog and seed move. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
try_parallel_map(list, f, Workers(at_once, each_ms, all_ms)) returns List[Result[U, TaskError]]. A fault in one item is that item's Err and siblings carry on. An item past each_ms, or running or unstarted when all_ms passes, is Err with R_DEADLINE; finished items keep their results. Blocking HTTP, command and socket calls inside an item wait no longer than the time left, so a hung server cannot hold an item past its deadline. Deadlines use a monotonic timer the program cannot read, so no clock grant. Timed items run on the interpreter. A recording marks an item that ran out of time as cut short and a replay makes it R_DEADLINE whatever its speed. Part of artifact format 76 (HigherOrder kind 11). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A together: block runs work in the background and ends all of it with the block. start(f, argument) begins a task on its own thread; wait(task) and wait_within(task, ms) give Result[T, TaskError], with R_DEADLINE and the task stopped when ms passes. A task not waited for is stopped when the block ends, and an error that unwinds past a block still stops its tasks. Tasks have exactly the parent's grants and share its memory and instruction budgets (the block takes three quarters of what is left and gives back what it did not use). A task output shows when it is waited for. Checked at compile time: start outside a block (E_START_OUTSIDE_TOGETHER), return, break, continue and ? leaving a block (E_TOGETHER_EXIT), and a task returned, printed or stored in a variable declared outside its block (E_SCOPE_ESCAPE). A recording keeps each task on its own lane and records each wait_within, so a replay makes the same choices. The browser playground reports that these need threads. Part of artifact format 76 (tags 211 to 214, HigherOrder kind 12; the Task type is never written into an artifact). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rst_ready, first_value Inside a together: block, let c: Channel[Int] = channel(8) makes a bounded queue. send waits while it is full, so a fast producer cannot get ahead of a slow consumer by more than the capacity; receive waits for a value and gives None once the channel is closed and empty; close closes it, and the block closes every channel it made when it ends. A started function can take a Channel[T] parameter but nothing can return one (E_SCOPE_ESCAPE). first_ready(tasks) and first_value(channels), with _within forms, give the position of the first item that is ready (the earliest in the list when several are). A recording keeps every send, receive and choice, so a replay makes the same ones whatever the timing (30 replays of a recorded race in the test). Part of artifact format 76 (tags 215 to 220, type tag 21). The agent reference is generated from language/spec.md and host-api.md, so the earlier hand edits to it were being overwritten; the text now lives in those sources. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e, process_close_input, process_wait std:process starts a granted command without waiting for it (the same grant, errors and fix-it text as process_run), reads its output a line at a time, writes to and closes its input, and waits for it. Each command runs in its own process group, and the whole group is stopped and reaped when the together: block that started it ends, when the program ends, and when guion is sent INT, TERM or HUP (a program that polls for signals itself handles them and still stops its commands when its block ends). Output is bounded per command. A Process cannot be returned from its block (E_SCOPE_ESCAPE). Recorded sessions replay with no command and no grant. Part of artifact format 76 (Process function codes 4 to 8). The design doc is marked built, with notes on where the build differs from it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…kers(at_once=50, ...) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e in the same step A channel value is taken under the channel's lock, so two consumers never get the same value or lose one. Ready[T] comes from std:process. Tapes can now read records whatever order their keys come in. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r block Compiles for x86_64-pc-windows-gnu; not yet run on Windows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lock ends Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…runner Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The python-interop feature had stopped compiling when values moved to shared pointers and new variants were added. Fixed, tests updated, and a Python call inside a try_parallel_map item now ends at that item's deadline. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Builds
docs/design-structured-concurrency.mdin artifact format 76 (one bump from 75).What it adds
[runtime] max_parallelism);core_count();R_PARALLEL_LIMITsays which line to change.try_parallel_map(list, f, Workers(at_once=…, each_ms=…, all_ms=…)): a result per item, with per-item and whole-run deadlines (R_DEADLINE).together:blocks withstart,wait,wait_within. Tasks get exactly the parent's grants, budgets are shared, and a task cannot leave its block.channel,send,receive,close) andfirst_ready/first_value, which returnReady(index, value)with the value taken in the same step.Ready[T]comes fromstd:process.start_process,process_line,process_write,process_close_input,process_wait): each in its own process group (Unix) or job object (Windows), stopped with everything it started when the block ends, the program ends, orguionis interrupted.Box(height=2, width=1); mistakes are named errors.Also fixed
python-interopfeature had stopped compiling after values moved to shared pointers. It builds again, its tests are updated, and a Python call inside a timed item now ends at the item's deadline.Checked
-D warningsandcargo fmt --checkclean; agent reference current; wasm build ok.windows-2025runner (cmdstartsping, the block ends, nopingis left) passes. Ctrl-C on Windows and the rest of the suite were not run there.mainand this branch measured in the same session withsession.py baselineandcompare. 26 Guion median ratios between 0.885 and 1.108, most within ±2%; the Python reference runs drifted +1–2% on their own. No clear regression;apps/sqlite-tomlread +10.8% on a short benchmark whileapps/file-dataread −11.5%, which I take to be noise but have not re-run.Not done / known limits
python-interopis not built by CI, so it can break again unnoticed.🤖 Generated with Claude Code