Skip to content

native: re-export kore-rt where a relayed wake reaches its waiter alone - #35

Draft
SnowCheetos wants to merge 5 commits into
ft/brave-heisenberg-zgoauxfrom
ft/admiring-lovelace-69eiok
Draft

SnowCheetos wants to merge 5 commits into
ft/brave-heisenberg-zgoauxfrom
ft/admiring-lovelace-69eiok

Conversation

@SnowCheetos

Copy link
Copy Markdown
Contributor

Summary

Re-exports Kore's kore-rt with the targeted relay (MicroPerceptron/kore#1540). A futex wake relayed through the thread controller now kicks only the threads its waker found waiting and could not kick, rather than every thread with a doorbell waiter registered. A C program's futex wakes take the controller's relay as before and reach fewer threads: a mutex or condition variable handed between two pthreads leaves the program's other parked threads asleep. No libkore crate changes.

Stacked on #33 (ft/brave-heisenberg-zgoaux).

What changed

  • native/, re-exported by tools/sync-native.py at Kore fba0662, the merge of MicroPerceptron/kore#1534's head into the relay branch, never edited by hand. The closure is 27 packages and 401 files. Against ffi: a cancellation wakes its target, and no cancellable wait polls #33's export (Kore 4a56f827), two things differ: kore-rt's futex.rs and thread_controller.rs (the relay), and services/swap/boot.toml, whose digests come from MicroPerceptron/kore#1534's reseal. native/Cargo.lock is ffi: a cancellation wakes its target, and no cancellable wait polls #33's, since no exported manifest changed; both lockfiles resolve with --locked.
  • docs/runtime.md: the controller kicks only the thread the waker found waiting.
  • docs/provenance.md: "A relayed wake reaches its waiter alone", with the design, why it loses no wake, and the metal evidence.

Commits

  • 021ecbe native: re-export at Kore 920526a, where a relayed wake reaches its waiter alone
  • a2561bb Merge the founding wait's re-export into the targeted relay's
  • 86aa302 docs: the targeted relay's evidence on the merged tree
  • 9808247 Merge #1494's later rounds' re-export into the targeted relay's: the revision Kore pins
  • 94bf557 docs: the targeted relay's evidence with all nine threads parked (docs only)

Verification

  • python3 tools/sync-native.py <kore> --revision fba0662 --check: the export matches upstream commit fba0662. tools/check-native.py: exact recorded source bytes, no untracked implementation files.

  • make fmt owners bindings-check test check docs cross miri: all pass on 94bf557. test passed 666, among them the exported kore-rt suite (471) with the relay's three tests; miri ran 91 across 15 binaries; cross checks x86_64, aarch64 and riscv64gc.

  • Kore's metal evidence, make keytest-tcc-x86 on the image built against 9808247 (Kore 09a98a0), with nine threads parked while two take 400 turns through a mutex and a condition variable:

    kore-rt futex and controller wakes that reached a parked thread tour
    this export (targeted relay) 0 exit 42
    MicroPerceptron/kore#1534's head (count and sweep) 1466 turns step failed

Note

The export lags Kore's reseal by design, as #33's does. native/ is byte-exact at its recorded revision fba0662, the merge, so its five exported services' boot.toml digests are MicroPerceptron/kore#1534's; Kore's reseal (09a98a0) moved them afterwards.


Generated by Claude Code

…aiter alone

## Why

Managed threads hold no send into each other's doorbells, so a futex
wake between two of them, such as a C mutex unlock or a condition signal
between two pthreads, is relayed through kore-rt's thread controller.
The relay was a count. The controller answered every relay by kicking
every thread with any doorbell waiter registered, so every relayed wake
woke every parked thread in the program. Kore `b67f198` makes the relay
name the threads it is for, and that arrives here through the exporter
rather than as edits to the snapshot.

## What

- `futex`: `Hub::relay(bands)` owes the hub the bands of the doorbell
  waiters its waker found and could not kick, before the hub's word
  moves. `wake` owes its first such waiter, `wake_all` all of them and
  `wake_thread` its target. `futex::deliver` kicks each owed band that
  still has a doorbell waiter registered, and never the hub itself.
- `thread_controller`: the parking controller takes what it is owed after
  reading its word and before parking on it (`Hub::take_owed`), and
  delivers it. `Owner::swept` is gone.
- The services' `boot.toml` digests are Kore's reseal over the change.
- `docs/runtime.md` says what a relayed wake between two managed threads
  costs: a kick into the controller and one out, however many threads
  are parked. `docs/provenance.md` records the export and Kore's metal
  evidence.

The closure keeps its 26 packages and 382 files. No exported manifest
changed, so `native/Cargo.lock` did not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ACHC7dri3nhVBsSLKqfP8S
Brings in ft/brave-heisenberg-zgoaux up to `c911ef1`, whose export
records Kore `40de2582`: a managed thread runs its callback only once
its founding is published, so it is reached from its first wait.

`native/` is not merged by hand. `tools/sync-native.py` re-exports it at
Kore `7b9bd96`, the merge of that founding wait into the targeted relay,
over this side's recorded export (Kore `920526a`). Against this side it
adds the founding wait to `thread_controller.rs`. Against that side it
adds the targeted relay to `futex.rs` and `thread_controller.rs`, and the
five services' `boot.toml` digests of the reseal over it (`920526a`),
which the founding wait leaves as they were.

`docs/provenance.md` keeps that branch's paragraph at the end of "A
cancellation is a wake" and restates "A relayed wake reaches its waiter
alone" for the new revision. `docs/runtime.md` merges as is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ACHC7dri3nhVBsSLKqfP8S
Kore's reseal over the export at `7b9bd96` (`e0717eb`, built from
`d64b7a5`, which pins `a2561bb`) repeats the turns step's A/B on the
merged tree. With the targeted relay, every step ran to `exit 42` and
no wake reached the parked thread. With the futex and controller of
`36b99426`, which count and sweep, it was woken 206 times and the tour
failed that step.

The two-thread bound the step runs under is this stack's: Kore #1494's
later `2a0730d` gives the controller's children their founder's arena,
which lifts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ACHC7dri3nhVBsSLKqfP8S
Brings in ft/brave-heisenberg-zgoaux up to `c839547`: its re-exports of
Kore #1494's newer rounds (founder arenas, a founding's staged space,
Kore's C library and stdio, descriptors and mmap for C programs, the
link window's free span) and the kore-ffi and kore-c halves they carry.

`native/` is not merged by hand. `tools/sync-native.py` re-exports it at
Kore `fba0662`, the merge of that branch's head into the targeted relay,
over this side's recorded export. The closure is now 27 packages and 401
files. Against that branch's export (Kore `4a56f827`) it differs in
kore-rt's `futex.rs` and `thread_controller.rs`, the targeted relay, and
in `services/swap/boot.toml`, whose digests come from that branch's
reseal (`83861dc9`). `native/Cargo.lock` is that branch's: no exported
manifest changed. Both lockfiles resolve with `--locked`.

`docs/provenance.md` keeps that branch's account of its two moves at the
end of "A cancellation is a wake", and restates "A relayed wake reaches
its waiter alone" for the new revision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ACHC7dri3nhVBsSLKqfP8S
Kore's reseal over the export at `fba0662` (`09a98a0`, built from
`8b617ee`, which pins `9808247`) measures the turns step with the founder's
arena, so the controller admits all eight threads the step parks beside
`main`. With the targeted relay, every step ran to `exit 42` and no wake
reached any of the nine. With the futex and controller of
`ft/brave-heisenberg-zgoaux`'s head (`83861dc9`), which count and sweep,
1466 wakes reached them over the 400 turns, and the tour failed that step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ACHC7dri3nhVBsSLKqfP8S
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.

2 participants