Skip to content

Replace runtime-based futex table with global static bucket table - #283

Merged
lalinsky merged 1 commit into
mainfrom
claude/issue-282-20260205-1655
Feb 5, 2026
Merged

lalinsky merged 1 commit into
mainfrom
claude/issue-282-20260205-1655

Conversation

@lalinsky

@lalinsky lalinsky commented Feb 5, 2026

Copy link
Copy Markdown
Owner

Implements #282

Converts the user-space futex implementation from using a runtime-stored bucket table to a global static bucket table.

Changes

  • Convert Futex.Table from dynamic allocation to fixed-size global static array (1024 buckets)
  • Remove runtime parameter from Futex.wait(), Futex.wake(), and Futex.timedWait() functions
  • Remove futex_table field from Runtime struct
  • Remove futex table initialization/deinitialization logic
  • Update all call sites in tests and runtime/group.zig
  • Update documentation to reflect simplified API

Benefits

  • Simpler API: No need to pass runtime parameter to futex functions
  • Reduced memory: No per-runtime allocation needed
  • Works globally: Futex operations now work across all runtimes in the same process

All 340 tests passed.

- Convert Futex.Table from dynamic allocation to fixed-size global
  static array (1024 buckets)
- Remove runtime parameter from Futex.wait(), Futex.wake(), and
  Futex.timedWait() functions
- Remove futex_table field from Runtime struct
- Remove futex table initialization/deinitialization logic
- Update all call sites in tests and runtime/group.zig
- Update documentation to reflect simplified API

This simplifies the futex API by eliminating the need to pass the
runtime parameter, as futex operations now use a global bucket table
that works across all runtimes in the same process.

Fixes #282

Co-authored-by: Lukáš Lalinský <[email protected]>
@coderabbitai

coderabbitai Bot commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR converts futex operations from per-runtime dynamic bucket tables to a fixed global bucket scheme. It removes the Runtime parameter from Futex.wait, timedWait, and wake, eliminates the futex_table field from Runtime, and updates all callsites in Group to match the new signatures.

Changes

Cohort / File(s) Summary
Runtime struct cleanup
src/runtime.zig
Removed the futex_table: Futex.Table field and its initialization/deinitialization logic from the Runtime struct.
Futex API refactor
src/sync/Futex.zig
Replaced per-runtime futex bucket tables with a fixed global bucket table. Updated wait(), timedWait(), and wake() to drop Runtime parameter; changed getBucket() to work with raw addresses; removed Table struct and dynamic sizing.
Group integration
src/runtime/group.zig
Updated Group.wait, Group.cancel, and unregisterGroupTask to use new Futex signatures without Runtime parameter; added unused rt parameter to unregisterGroupTask.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🌍 From scattered tables to one throne,
Futex claims a global home,
Runtime freed from bucket care,
Address-based, everywhere. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately describes the main architectural change: replacing a per-runtime futex table with a global static one.
Description check ✅ Passed The description clearly explains what was changed, why, and the concrete benefits, with test results confirming functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/issue-282-20260205-1655

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 and usage tips.

@lalinsky
lalinsky merged commit 54330b6 into main Feb 5, 2026
6 checks passed
@lalinsky
lalinsky deleted the claude/issue-282-20260205-1655 branch February 5, 2026 17:38
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