Skip to content

Normalize WASI deadline-event accounting (I02) - #28

Merged
proggeramlug merged 2 commits into
mainfrom
lane/tl-i02
Sep 15, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
lane/tl-i02

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Implements remaining-work item I02. Report: docs/lanes/tl-i02.md.

Both WASI backends counted a quiet deadline expiry as native work, so a timer-only wake reported zero_event_waits == 0 and the no-spin gates could not see a spin there. Native backends already normalize this (IOCP explicitly, epoll through its private timerfd).

  • WASI 0.2: poll appends the private deadline pollable without an owners entry, but passed indices.is_empty(). It now counts native events in the existing dispatch loop (indices resolving to a socket or DNS owner) and passes native_events == 0. No extra pass, no allocation.
  • WASI 0.3: empty was kind == 0, but a quiet expiry returns one event whose waitable is the deadline subtask. That event is now hoisted into deadline_event, reused for the existing cancellation decision, skipped in the operation scan, and empty becomes kind == 0 || deadline_event.
  • Driver unchanged: a private deadline wake is an empty blocking wait, which the Queued turns never block; count zero-timeout discovery polls separately (I01) #20 waits/discovery_polls split already expresses.
  • Contract text updated in backend/mod.rs rustdoc, DESIGN §10 rule 4a, docs/BACKEND_REVISION_2.md and CONTRIBUTING.md.

Tests

New shared contract quiet_deadline_accounting, instantiated natively, on both WASI arms and on Windows. Per expiry at 0.5/2/10 ms: exactly one native call, zero_event_waits == 1, one turn, exact deadline; identical totals idle and with a registered-but-idle read; plus a control where that read takes real bytes and the call must not count as zero-event. The existing quiet-deadline allocation gate now runs on both WASI targets too.

Mutation-proved both directions: reverting either backend fails with left: (1, 0) right: (1, 1); over-normalizing (empty = true) fails the real-I/O control.

Verification

macOS native (1645 tests), WASI 0.2 and 0.3 runtime on wasmtime 46, strict clippy across native, Linux (both epoll modes), Windows, wasip2, wasip3 and web, stable check, rustdoc, no-tokio and soak. Linux and Windows runtime run in this PR's CI.

Ralph Küpper added 2 commits September 15, 2026 10:41
The WASI backends counted their own deadline wake as native work, so a
timer-only wake reported zero zero-event OS waits and DESIGN section 10
rule 4a's no-spin bound could not see it.

WASI 0.2 appends its deadline pollable after the owned handles, so its
readiness has no owners entry: count only socket and DNS indices. WASI 0.3
joins a deadline subtask to the wait set: recognize an event whose waitable
is that subtask, skip the operation scan for it and report the step as
empty. Real socket, DNS and notifier events in the same call still count.

Shared contract quiet_deadline_accounting proves, for the three design
delays, that each of sixty expiries costs exactly one blocking wait that
observed no native event, identically idle and with a registered-but-idle
read, and that a call carrying real bytes is not counted empty. The
quiet-deadline allocation gate now runs on both WASI targets and covers the
registered-but-idle phase.
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: af4992cf-6aee-4fc3-b680-5fb14d2161c1

📥 Commits

Reviewing files that changed from the base of the PR and between 7e367cd and dd93fa9.

📒 Files selected for processing (11)
  • CONTRIBUTING.md
  • DESIGN.md
  • crates/turnloop-contract/src/lib.rs
  • crates/turnloop-contract/tests/allocations.rs
  • crates/turnloop-contract/tests/wasi.rs
  • crates/turnloop-contract/tests/windows.rs
  • crates/turnloop/src/backend/mod.rs
  • crates/turnloop/src/backend/wasi_p2.rs
  • crates/turnloop/src/backend/wasi_p3.rs
  • docs/BACKEND_REVISION_2.md
  • docs/lanes/tl-i02.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug merged commit d5e4113 into main Sep 15, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant