Skip to content

perf(native): keep attached machine code in file mappings - #2480

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4
Oct 28, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4

Conversation

@tignear

@tignear tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Loading an attached image allocated an owned copy of its machine code before
copying it again into executable memory. Retain immutable mapped code with Arc
ownership and use aligned file pages directly on Linux x86-64. Unsupported or
unaligned mappings retain the anonymous executable allocation path.

Align newly attached code to 4 KiB, or 2 MiB for large images. A checksummed
optional prefix descriptor records the original runtime length so replacement
across Postcard length boundaries cannot accumulate padding. The Postcard
payload, generic Serde representation and container version remain compatible.

Keep image bytes and offset resolution tied to a private immutable base, even
when callers replace the public entry pointer. Cover both owned and external
backing lifetimes with entry-swap and owner-drop regressions.

Validation: 20 native units, 627 x86 backend units, 36 native image/cache
consumer tests, 68 VPI unit/API tests, 10 cocotb integrations, 330 native common
cases (including wide, four-state and parallel execution), affected-target
clippy with warnings denied, and formatting. Regressions cover retained owner
lifetimes, legacy payload encoding, bounded replacement and corrupt padding.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T19:42:56.258543Z 943ba42 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.

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 28, 2026

@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: 11e6b51e1e

ℹ️ 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".

&self._mmap
// Safety: either owned mapping or external owner keeps this immutable
// executable region alive for the lifetime of this borrow.
unsafe { std::slice::from_raw_parts(self.fn_ptr as *const u8, self.code_len) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the image base independent of the mutable entry pointer

Because fn_ptr is a public writable field, safe callers can swap it between two JitCode instances and then drop one instance. image() now constructs its slice from that replaceable pointer while retaining the original allocation's length and owner, so this sequence can produce a slice into unmapped memory; even without dropping either instance, differing allocation sizes can cause an out-of-bounds slice. Previously, image() borrowed the owned mapping directly and was unaffected by changes to fn_ptr. Retain a private immutable region-base pointer for both image() and entry_ptr() rather than deriving their addresses from the public entry pointer.

Useful? React with 👍 / 👎.

@tignear tignear removed the merge-ready Request merging through Mergify after required checks label Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

@tignear

tignear commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 perf(native): keep attached machine code in file mappings #2480 👈
2 fix(native): retain image base across entry pointer changes #2485

Loading an attached image allocated an owned copy of its machine code before
copying it again into executable memory. Retain immutable mapped code with Arc
ownership and use aligned file pages directly on Linux x86-64. Unsupported or
unaligned mappings retain the anonymous executable allocation path.

Align newly attached code to 4 KiB, or 2 MiB for large images. A checksummed
optional prefix descriptor records the original runtime length so replacement
across Postcard length boundaries cannot accumulate padding. The Postcard
payload, generic Serde representation and container version remain compatible.

Keep image bytes and offset resolution tied to a private immutable base, even
when callers replace the public entry pointer. Cover both owned and external
backing lifetimes with entry-swap and owner-drop regressions.

Validation: 20 native units, 627 x86 backend units, 36 native image/cache
consumer tests, 68 VPI unit/API tests, 10 cocotb integrations, 330 native common
cases (including wide, four-state and parallel execution), affected-target
clippy with warnings denied, and formatting. Regressions cover retained owner
lifetimes, legacy payload encoding, bounded replacement and corrupt padding.

Change-Id: Idc33e7f4db1b90e2cf48d03f0fd39049aebda302
@tignear
tignear force-pushed the stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4 branch from 11e6b51 to 943ba42 Compare October 28, 2026 19:41
@tignear

tignear commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 11e6b51 2026-10-28 19:41 UTC
2 content 11e6b51 → 943ba42 (raw) User requested squashing PR #2485 into #2480. Fold the reviewed image-base lifetime fix into its introducing commit; preserve the final validated source tree and the original PR Change-Id. 2026-10-28 19:41 UTC

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 28, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into master as 5fcbf1f at 21:09 UTC

Merged together with #2487. 34 min in the queue, 13 min of it CI.

So far

Merge conditions: 7 of 7 met

The batch, tested on draft #2489

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/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/Conventional Commit title, check-neutral = @github-actions/Conventional Commit title, check-skipped = @github-actions/Conventional Commit title GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Queue validation, check-neutral = @github-actions/Queue validation, check-skipped = @github-actions/Queue validation GitHub repository ruleset rule master

Times in UTC · dashboard · how the merge queue works

@mergify
mergify Bot merged commit 5fcbf1f into master Oct 28, 2026
24 checks passed
@mergify
mergify Bot deleted the stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4 branch October 28, 2026 21:09
@mergify mergify Bot removed the queued Mergify queue entry label Oct 28, 2026
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