Skip to content

Commit 55aefdd

Browse files
committed
fixup! docs: add some design docs
1 parent 69126a7 commit 55aefdd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs/blog/v05-async-suspension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn run_yields_before_ret_in_call_ret_sequence_when_out_of_fuel() {
195195

196196
## Where This Falls Short
197197

198-
- **No mid-expression suspension.** Yielding only at call boundaries means a script can't suspend inside a complex expression like `f(g(x), h(y))` between the `g(x)` and `h(y)` calls. The VM must complete each inner call before suspending on the outer one. For most proxy scripts this is fine, but it rules out patterns like "start two I/O operations concurrently from the same expression."
198+
- **Single pending operation.** The VM tracks exactly one `waiting_host_op` at a time. Each `Call` opcode is an independent suspension point — in `f(g(x), h(y))`, `g(x)` can `Pending`, complete, and then `h(y)` can `Pending` separately. But the VM cannot start both operations concurrently. Scripts that need fan-out (e.g., fire three subrequests in parallel) must do so through a host function that internally manages the concurrency and returns a single `Pending`.
199199
- **Yield requires host idempotency.** `CallOutcome::Yield` replays the entire call from scratch. If the host function has side effects (e.g., it incremented a counter before yielding), those effects happen twice. The host must be designed around this, which limits which operations can use the `Yield` mechanism.
200200
- **No script-level concurrency.** The VM is single-threaded by design. A script cannot spawn parallel tasks or await multiple I/O operations simultaneously. Concurrency is handled by the host (pd-edge's DAG scheduler and Tokio tasks), not by the script. Scripts that need fan-out patterns must issue sequential subrequests.
201201
- **Fuel granularity is approximate.** The `fuel_check_interval` means the VM can overshoot its fuel budget by up to N instructions. For intervals of 256, a script allocated 1000 fuel units might execute up to ~1256 instructions before the check fires. This is acceptable for resource limiting but not suitable for precise instruction counting.

0 commit comments

Comments
 (0)