Skip to content

refactor(native): support state-aware outlined kernel calls - #2231

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/perf/taxi-memory-runtime/support-state-aware-outlined-kernel-calls--a444d9f7
Oct 27, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/perf/taxi-memory-runtime/support-state-aware-outlined-kernel-calls--a444d9f7

Conversation

@tignear

@tignear tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Add an internal image-local call ABI with a hidden state pointer, signed status propagation, and preservation of pinned host state. Treat these callees as opaque state effects in SIR memory passes and invalidate cached load origins across calls. Ordinary DPI imports keep their existing ABI.

Validation: SIR, optimizer and x86 unit suites; native-call regressions cover zero, positive and negative status values, pinned R15/GS state, tick-loop state and live vector values. Memory regressions prevent forwarding or reloading overwritten state across a kernel call. Owning-crate clippy and formatting pass.
Generated-kernel callers now require explicit complete callee arena bounds; emission without them is rejected. The direct emit_with_callees entry and X86BackendOptions::with_native_callees reserve the caller above every callee's full required_state_size, including nested reservations. Existing explicit arena placements remain supported by the prepared pipeline.

A regression reproduced the review finding with two generated functions emitted at the same 4096-byte semantic state size: the caller's last seven spilled values became zero. The fixed test supplies the actual emitted callee extent. Three-level generated call regressions force spills at every level, cover R15/GS and tick-loop entry, propagate zero, positive and wide negative status values, and reject missing or overflowing arena bounds. All 623 x86 unit tests and owning-crate clippy pass.

@tignear

tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 refactor(native): support state-aware outlined kernel calls #2231 👈
2 perf(native): share large comb kernels and bound compilation memory #2232
3 fix(vpi): expose interface parameters and lexical generate scopes #2233
4 perf(settle): bound estimated partitions and preserve sparse updates #2234
5 perf(sv): evaluate stateless constant functions once #2235

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T09:54:32.296039Z 05cf8e2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af5bc1e448

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// The heap helper takes the state pointer before the staged arguments.
let heap = func == celox_sir::extern_abi::HEAP_HELPER_ID;
let leading = usize::from(heap);
let leading = usize::from(heap || kernel.is_some());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Isolate native callees from the caller's live arena

When the target is another generated function emitted with the same simulation-state size, passing the unchanged state pointer also shares the caller's spill and scratch storage: NativeArenaLayout::build sets each function's spill_base to align16(state_size). A callee that spills therefore overwrites caller values spilled across this call, and nested calls can also overwrite saved pinned registers when their call areas overlap. The added regression uses a Rust callee, which never accesses this arena and consequently cannot expose the corruption. Allocate disjoint per-function/per-call arena storage, or preserve the caller's live arena around generated-kernel calls.

Useful? React with 👍 / 👎.

@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@tignear
tignear force-pushed the stack/tignear/perf/taxi-memory-runtime/support-state-aware-outlined-kernel-calls--a444d9f7 branch from af5bc1e to 04e3dc9 Compare October 27, 2026 06:19
@tignear

tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial af5bc1e 2026-10-27 06:18 UTC
2 content af5bc1e → 04e3dc9 Address review 4385415960: require an explicit generated-callee arena footprint, reserve disjoint caller storage, and test real generated spill-heavy nested callees rather than only a Rust surrogate. 2026-10-27 06:18 UTC
3 rebase 04e3dc9 → 05cf8e2 (rebase only) Rebase the unchanged native ABI member onto master after #2229 and #2230 merged, keeping the performance stack bases synchronized. 2026-10-27 09:51 UTC

Base automatically changed from stack/tignear/perf/taxi-memory-runtime/avoid-copying-published-discovery-prefixes--2d3a1a30 to master October 27, 2026 07:37
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 27, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

1 h 33 min in the queue, with no time running CI.

So far

Reason

The pull request #2231 has been manually updated

Merge conditions: 9 of 11 met

This pull request

Condition
✅ depends-on=celox-sim/celox#2231
✅ any of: depends-on = celox-sim/celox#2230, number != 2231

The batch, tested on draft #2256

Condition Required by
❌ check-success = Queue validation —
❌ any of: check-neutral = @github-actions/Rust Test & NAPI Build, check-skipped = @github-actions/Rust Test & NAPI Build, check-success = @github-actions/Rust Test & NAPI Build GitHub repository ruleset rule master
✅ check-success = Conventional Commit title —
✅ any of: check-success = @github-actions/Lint & Format, check-neutral = @github-actions/Lint & Format, check-skipped = @github-actions/Lint & Format GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/NAPI Build (Linux ARM64 GNU), check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU), check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/NAPI Build (Windows), check-neutral = @github-actions/NAPI Build (Windows), check-skipped = @github-actions/NAPI Build (Windows) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/JS Test (Ubuntu), check-neutral = @github-actions/JS Test (Ubuntu), check-skipped = @github-actions/JS Test (Ubuntu) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/JS Test (Windows), check-neutral = @github-actions/JS Test (Windows), check-skipped = @github-actions/JS Test (Windows) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Conventional Commit title, check-neutral = @github-actions/Conventional Commit title, check-skipped = @github-actions/Conventional Commit title GitHub repository ruleset rule master

Requeued — the merge queue status continues in this comment ↓.

Times in UTC · dashboard · how the merge queue works

Add an internal image-local call ABI with a hidden state pointer, signed status propagation, and preservation of pinned host state. Treat these callees as opaque state effects in SIR memory passes and invalidate cached load origins across calls. Ordinary DPI imports keep their existing ABI.

Validation: SIR, optimizer and x86 unit suites; native-call regressions cover zero, positive and negative status values, pinned R15/GS state, tick-loop state and live vector values. Memory regressions prevent forwarding or reloading overwritten state across a kernel call. Owning-crate clippy and formatting pass.
Generated-kernel callers now require explicit complete callee arena bounds; emission without them is rejected. The direct emit_with_callees entry and X86BackendOptions::with_native_callees reserve the caller above every callee's full required_state_size, including nested reservations. Existing explicit arena placements remain supported by the prepared pipeline.

A regression reproduced the review finding with two generated functions emitted at the same 4096-byte semantic state size: the caller's last seven spilled values became zero. The fixed test supplies the actual emitted callee extent. Three-level generated call regressions force spills at every level, cover R15/GS and tick-loop entry, propagate zero, positive and wide negative status values, and reject missing or overflowing arena bounds. All 623 x86 unit tests and owning-crate clippy pass.

Change-Id: Ia444d9f7754e3f118e5a3945b32360c2acd7298d
@tignear

tignear commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into master as 6269353 at 11:58 UTC

Merged together with #2232, #2233. 1 h 27 min in the queue, 29 min of it CI.

So far

Merge conditions: 11 of 11 met

This pull request

Condition
✅ depends-on=celox-sim/celox#2231
✅ depends-on=celox-sim/celox#2232

The batch, tested on draft #2268

Condition Required by
✅ check-success = Conventional Commit title —
✅ check-success = Queue validation —
✅ any of: check-success = @github-actions/Lint & Format, check-neutral = @github-actions/Lint & Format, check-skipped = @github-actions/Lint & Format GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/NAPI Build (Linux ARM64 GNU), check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU), check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/NAPI Build (Windows), check-neutral = @github-actions/NAPI Build (Windows), check-skipped = @github-actions/NAPI Build (Windows) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Rust Test & NAPI Build, check-neutral = @github-actions/Rust Test & NAPI Build, check-skipped = @github-actions/Rust Test & NAPI Build GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/JS Test (Ubuntu), check-neutral = @github-actions/JS Test (Ubuntu), check-skipped = @github-actions/JS Test (Ubuntu) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/JS Test (Windows), check-neutral = @github-actions/JS Test (Windows), check-skipped = @github-actions/JS Test (Windows) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Conventional Commit title, check-neutral = @github-actions/Conventional Commit title, check-skipped = @github-actions/Conventional Commit title GitHub repository ruleset rule master

Times in UTC · dashboard · how the merge queue works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant