Skip to content

Mark NonNull read family and offset_from as inline(always) - #161004

Open
zakrad wants to merge 1 commit into
rust-lang:mainfrom
zakrad:fix-nonnull-read-inline
Open

Mark NonNull read family and offset_from as inline(always)#161004
zakrad wants to merge 1 commit into
rust-lang:mainfrom
zakrad:fix-nonnull-read-inline

Conversation

@zakrad

@zakrad zakrad commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

These are one line wrappers that just forward to the raw pointer funcs that are all #[inline(always)], as are NonNull's own write and offset, The read and offset_from were left as plain #[inline]

read, read_volatile, read_unaligned, and offset_from are the only NonNull
pointer methods still marked inline; the other 17 are inline(always), as are
the raw const/mut pointer equivalents. They are one-line delegating wrappers,
so make them consistent -- they now inline in debug like their siblings.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 12, 2026
@rustbot

rustbot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from JohnTitor, Mark-Simulacrum, clarfonthey, nia-e

@clarfonthey

Copy link
Copy Markdown
Contributor

Do you have any particular evidence this helps? I figure it probably does, but I could be wrong.

@zakrad

zakrad commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Do you have any particular evidence this helps? I figure it probably does, but I could be wrong.

The raw pointer funcs these wrap are #[inline(always)] #160816 NonNull read + offset_from left out, codegen wise the difference shows in debug, at -Copt-level=0 #[inline] stays an out of line call, while #[inline(always)] gets inlined, its not a release perf change but consistency plus tiny unoptimized codegen

@clarfonthey

Copy link
Copy Markdown
Contributor

Right, I know what inline(always) does, but I mostly am asking whether this actually noticeably improves performance without affecting build times, since that's not always clear.

@zakrad

zakrad commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

No evidence it does, it was mostly for consistency, we can have perf run tho

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants