Repository navigation
Conversation
YidaWeng
left a comment
There was a problem hiding this comment.
Thanks — the fix is right, and I re-ran your harness on the platform you couldn't.
Independent run: macOS arm64
Apple M2 Pro / macOS 27.2 / Apple clang 21.0.0, current main (f0ddfe7b). One portability change was needed: macOS has no pthread_barrier_*, so I replaced the barrier with an _Atomic u32 start flag (release by the main thread, acquire spin in the writer). Everything else is your harness as posted.
- Unpatched: TSan reports two distinct races, one per read, both in the emitted
runtime.crow_grow— theput0[i] = *ring_put(...)snapshot and the*ring_get(...)comparison (lines 1775 and 1776 of the generated C here). The harness's own assertions still pass. - Patched: no reports in three consecutive runs, 8,192 real
row_growcalls at each of strides 1 and 128, with the finalput/getcounters, slot data and published lap assertions passing.
One macOS note for the recipe: this run exits 134 (abort) even with TSAN_OPTIONS=exitcode=66, so the exit code isn't the signal on Apple silicon — the two reports are.
That covers the macOS entry in your qualification list. I did not run Windows, the GPU lanes or the mini-cluster.
The change
Correct, and at the right strength. These counters are only sampled; the ordering that matters comes from the slot publication (a32_store_rel(lo + 1) / a32_load_acq) and the round handoff, so relaxed is what is wanted, and ring_push already reads get through a32_load. I also checked the two plain get reads you left alone — the drain loop at 4760 and monk_step's *get at 4452. Both read the calling row's own word, and pool_turn joins rounds before returning, so they don't need to change. Scoping the PR to row_grow is right.
One question on the second report
Can a thread other than the row's owner advance that row's get? I traced the paths I could find — row_grow always consumes base + i * stride; the drain branch consumes its own band (row + r % step, stepping by step inside row .. row + CUBE_T); the only other row_grow caller is cube_run, before the pool starts; and rounds are joined through pool_done — and I could not find one. If that holds, the second TSan report comes from the harness's writer advancing get itself, and the get half of the patch is defense-in-depth rather than a fix for a peer writer in the scheduler. I'd keep it either way (it is free and makes the snapshot atomic by construction); I'd just like the PR body to say which of the two reads has a real peer. If you know a path I missed, ignore this.
CHANGELOG
Is ## Unreleased the new convention? The history I see writes notes in the release commit (Bend 2.0.40), and the one recent non-release CHANGELOG edit (#1933) appended to the then-current release section. Happy to leave it if this has been agreed with Taelin; I just don't want to guess.
Size
65,974 → 65,980 ttok on current main (+6); your 65,983 on 335f239a is consistent. bun gates/repo.ts is 56/56 here.
Nothing blocking from me. With a mini-cluster run I would call it ready.
|
Yep, I found no peer
|
|
Can someone with access run the required mini gates on a4974d5? The documented cluster alias is unavailable here, and I also cannot access bendlang/bend-lang.com for the installer gate. I am keeping this draft rather than treating the local Linux checks as equivalent. |
|
Re-ran the updated recipe, verbatim as posted, at the current head on macOS. It works there, and the exit code is usable after all. macOS arm64,
|
| build | runs | reports | exit |
|---|---|---|---|
| unpatched | 3 | 2 each | 134 |
| patched | 3 | 0 | 0 |
Both strides pass the counter, slot and lap assertions in every run.
The two unpatched reports land exactly where you said they would:
- write in
ring_push(runtime.c:1138, theputadvance) vs read atrow_growruntime.c:1775— the real peer producer; - the harness's own
a32_store_rel(ring_get(...))(harness line 19) vs read atrow_growruntime.c:1776— counter stress only.
So the split in the body is right, and on the emitted C as of d18110b6 those are still lines 1775 and 1776.
One correction to the note about Apple: the 134 in my earlier run came from my pthread_barrier_* replacement, not from the platform. With your C11 start flag the patched build exits 0 consistently, so on this harness the exit code is a fine signal — nonzero means reports, zero means clean. TSAN_OPTIONS=exitcode=66 still has no effect on Apple silicon (the unpatched run aborts with 134 despite it), but nothing needs it.
Size on the current head
main moved to d18110b6 (#2108), which took comp.ts from 65,974 to 65,938 ttok. With this patch it is 65,944, so +6 and 56 tokens under the 66,000 cap.
CHANGELOG
Resolved as far as I'm concerned. v2.0.40 was published 2026-11-06, and #1933 (b0df1666, 2026-10-29) appended a fix note to the already-released 2.0.39 section the same way, so adding to 2.0.40 is the established pattern and not an unreleased-section guess. (It will not show on the published 2.0.40 release page, but neither did #1933's.)
Mini gates
I don't have cluster access either, so I can't run them — the macOS harness, the size check and my review are all I can add. Staying draft until someone runs the mini gates is the right call. Windows, GPU lanes and the mini-cluster remain unqualified by me.
Closes #2104.
row_grownow uses the existing relaxeda32_loadhelper for its ring-cursor snapshots. The production peer-writer race is onput:ring_pushadvances it while another row samples it. Existing slot publication and round-handoff ordering stay unchanged.I found no peer
getwriter in the host scheduler paths checked here: grow bands and drain residues are disjoint,monk_stepadvances the owned cursor, andring_rewindruns after the pool round joins. Thegetload stays atomic for consistent sampling. The harness deliberately advancesgetfrom its writer thread, so its second TSan report is counter stress, not evidence of a scheduler peer consuming the same row.Locally on Linux, the portable harness below passes 8,192 real
row_growcalls at each of strides 1 and 128 with no TSan reports; counters, slot data and published lap are checked. It includes Bend’s complete emitted C, not copied runtime functions.bun gates/repo.ts: 56/56. The compiler file is unchanged by this review follow-up (65,983 / 66,000 tokens).YidaWeng’s updated independent macOS run applied
a4974d57to maind18110b6on M2 Pro / macOS 27.2 / Apple clang 21, using the posted C11 recipe unchanged. Three unpatched runs each reported the realputrace and the artificialgetcounter stress and exited 134; all three patched runs passed the assertions with no reports and exited 0. This is reviewer-reported evidence, not my own macOS run. Windows, GPU execution and mini-cluster gates remain unqualified; the PR stays draft.Native reproduction
Save this as
row-grow-race.c, then emit the runtime and compile it:On unpatched
335f239a, the original Linux stress run reported the plain counter reads; the patched portable recipe exits 0 locally. With this C11 recipe, YidaWeng reports exit 134 for unpatched and 0 for patched on Apple silicon;TSAN_OPTIONS=exitcode=66does not override the unpatched abort. The earlier barrier replacement was not evidence about this harness’s exit status. Check the reports and assertions alongside the exit code. The C11 release/acquire start flag avoids macOS’s missingpthread_barrier_*.AI-assisted.