Skip to content

core: thread tests wait on the clock, not a count of yields - #239

Merged
foxnne merged 1 commit into
mainfrom
core/test-waits-on-clock
Oct 8, 2026
Merged

foxnne merged 1 commit into
mainfrom
core/test-waits-on-clock

Conversation

@foxnne

@foxnne foxnne commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

What changes

Fixes the macOS failure in #234's CI: LocalFs "a read lands through pump" failed with error.NeverLanded. #234 itself changes only ci.yml, and the same test passed on macOS in #234's previous run and in #228's.

Cause. The read runs on the Io's thread pool, and the test pumped and yielded 200,000 times before giving up. When the read thread is waiting on the disk, not the CPU, each yield returns at once. I measured the full budget:

Condition 200,000 yields take
Idle M-series Mac 20 ms
Background priority 125 ms
CPU saturated 1.2–54 s (each yield hands the core away)

So a runner whose disk took more than about 20–50 ms to answer failed the test. Loading the CPU makes the test more tolerant, which is why my reproduction attempts under load all passed: 0/80 runs of the test binary and 0/15 warm zig build test runs at background priority.

Reproduced directly: with the read delayed by 100 ms, the old test fails with exactly CI's error (NeverLanded at LocalFs.zig:393), and the new one passes.

Now:

  • LocalFs "a read lands through pump" pumps until the read lands or 10 s pass on std.Io.Clock.boot, and stops the moment it lands, so it's no slower when things are fast. It also keeps the read's error. The old sink dropped it, so a read that failed also showed up as "never landed". A future failure will now say which of the two it was.
  • The same count-of-yields wait was in three core/work.zig thread-mode tests (100,000 yields, about 10 ms) and in FileTable's "rename onto a mount" test. They now wait on the clock the same way, written inline at each site.

SDK impact

  • None. Tests only.

Verified

  • macOS (local): zig build test passes 71/71 steps and 491/492 tests (the one skip is the existing lsp-uri one). The file-table tests pass 43/43 and the work tests 4/4.
  • The read delayed 100 ms: the old test fails with NeverLanded; the new one passes. The delay was temporary and is not in this diff.
  • Linux, Windows: this PR's CI.

Follow-ups

🤖 Generated with Claude Code

"a read lands through pump" failed on a macOS runner (#234's CI) as `error.NeverLanded`. The read
runs on the `Io`'s pool, and the test gave up after 200,000 yields; a yield returns at once when
the other thread is waiting on the disk rather than the CPU, so that was about 20 ms of wall time
on an idle Mac. A runner whose disk answered slower failed it. Delaying the read by 100 ms
reproduces the failure exactly on the old test; the new one passes.

The test now pumps until the read lands or 10 s pass on `std.Io.Clock.boot`, and keeps the
read's error, so a failure says whether the read never landed or landed as an error (the old sink
dropped the error, which read as "never landed" too). The same count-of-yields wait was in three
`core/work.zig` thread-mode tests (100,000 yields, ~10 ms) and FileTable's rename onto a mount;
they wait on the clock the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@foxnne
foxnne merged commit ada6a04 into main Oct 8, 2026
9 checks passed
@foxnne
foxnne deleted the core/test-waits-on-clock branch October 8, 2026 15:07
foxnne pushed a commit that referenced this pull request Oct 8, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Euk6iCavQdW7MG5FN2vvFw
foxnne added a commit that referenced this pull request Oct 8, 2026
Part of #226

## What changes

Two pieces pixi's dropper magnifier (fizzyedit/pixi#3) needs to be a
clear liquid orb over its zoom, with no frost and strong refraction:
native Liquid Glass on macOS, the app's glass everywhere else. And the
SDK release that ships them, so the orb can be tried against `main` as
soon as this merges.

**`core.native_glass.offered`**
- The app publishes each frame whether the OS draws glass declared
outside a view drag (`publishOffered`, from `Popout.beginFrame`'s
`nativeGlass()`).
- A plugin that sees it declares its glass with `native_glass.add`.
Fizzy's overlay of Liquid Glass already stays up while any glass is
declared.
- Pixi declares a clear piece (`frost = 0`, the lens alone) over a zoom
it draws in the window, so the OS's lens refracts the window beneath.
- Off macOS 26, or with native glass off, `offered()` is false.

**`LiquidField.drawPicture` / `pictureMargin` / `lens`, and
`glass_look.forLens`**
- The app's glass as a lens over a picture the plugin drew. The middle
is the picture as it is, with no frost, colour or lift; the rim bends
and lights it.
- It reads no capture, so the middle stays pixel-exact.
- On the web, where no look is published, it is the earlier glass.
`pictureMargin` says how far past the shapes the picture should reach
for that glass's rim, at the strongest shape lens.

**Tried and dropped:** pixi tried the drop zones' frosted glass with its
zoom laid over it. On a Mac it read as a thick grey border or a flat
rim.

**Merged with main** (#234–#236, #239, #240).

## SDK impact

- [ ] None
- [ ] Core-only or additive: reaches plugins at the next SDK release
- [ ] Fingerprint moved: recorded in `sdk/src/version.zig`,
`sdk_version` untouched, PR labelled `sdk`
- [x] SDK release: bumps `sdk_version`, lists the `sdk` PRs since the
last `sdk-v*` tag

`sdk_version` goes 0.2.17 → 0.2.18 (ef95301). Since `sdk-v0.2.17` this
release carries:
- this PR's core additions;
- #223, #224 and #227's core (the one-slider glass, `glass_look`,
`core.native_glass`, `core.screens`'s menus and dialogs).

The fingerprint has not moved, so installed plugins keep loading.
Merging tags `sdk-v0.2.18` and, per #240, asks the store plugins to
repin.

## Verified

- `zig test core/gfx/glass_look.zig`: 13 pass.
- `zig fmt --check` and `zig ast-check` on the changed files.
- `tests/integration.zig` compiles `drawPicture` and checks
`pictureMargin`.
- CI: Linux, macOS, Windows, integration and the Windows cross-build on
this head.
- [x] macOS: pixi's orb tried locally against this branch by the
maintainer, who approved it.
- [ ] Windows:
- [ ] Linux:
- [ ] Web:

## Follow-ups

- pixi#3 repinned to `sdk-v0.2.18` once it's tagged.
- The orb pinching off pixi's sample button and merging with it (the
plan's next step for this consumer).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Euk6iCavQdW7MG5FN2vvFw

---------

Co-authored-by: Claude <noreply@anthropic.com>
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