Skip to content

Introduce --cfg zerocopy_inline_always#3139

Merged
joshlf merged 1 commit into
mainfrom
G750518420a745aec19276f7a24bcd0f66584bb2c
Mar 20, 2026
Merged

Introduce --cfg zerocopy_inline_always#3139
joshlf merged 1 commit into
mainfrom
G750518420a745aec19276f7a24bcd0f66584bb2c

Conversation

@jswrenn

@jswrenn jswrenn commented Mar 19, 2026

Copy link
Copy Markdown
Collaborator

Enables customers to tune inlining aggressiveness of many of zerocopy's
public functions. At higher codegen-units, the Rust compiler may fail
to inline invocations of conversion functions. Applying the
#[inline(always)] attribute (as in #3137) forces inlining, but that
might not be desirable for all monomorphizations or invocations.
Dynamically padded types, for instance, require much more complex
codegen than statically sized for unpadded dynamically sized types.

While reducing codegen-units for a build can improve codegen, it
carries a large penalty in build times. The --cfg zerocopy_inline_always
flag provides a narrowly-scoped lever for achieving some of the
benefits of codegen-units=1 without the broad build time penalties.


Latest Update: v6 — Compare vs v5

📚 Full Patch History

Links show the diff between the row version and the column version.

Version v5 v4 v3 v2 v1 Base
v6 vs v5 vs v4 vs v3 vs v2 vs v1 vs Base
v5 vs v4 vs v3 vs v2 vs v1 vs Base
v4 vs v3 vs v2 vs v1 vs Base
v3 vs v2 vs v1 vs Base
v2 vs v1 vs Base
v1 vs Base
⬇️ Download this PR

Branch

git fetch origin refs/heads/G750518420a745aec19276f7a24bcd0f66584bb2c && git checkout -b pr-G750518420a745aec19276f7a24bcd0f66584bb2c FETCH_HEAD

Checkout

git fetch origin refs/heads/G750518420a745aec19276f7a24bcd0f66584bb2c && git checkout FETCH_HEAD

Cherry Pick

git fetch origin refs/heads/G750518420a745aec19276f7a24bcd0f66584bb2c && git cherry-pick FETCH_HEAD

Pull

git pull origin refs/heads/G750518420a745aec19276f7a24bcd0f66584bb2c

Stacked PRs enabled by GHerrit.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new configuration flag, --cfg zerocopy_inline_always, designed to give users finer control over compiler inlining behavior for core zerocopy functions. This allows for targeted performance improvements in critical code paths by forcing aggressive inlining, offering a more granular approach than global compiler settings and avoiding their associated build time overheads. The change also includes updates to benchmark results, likely reflecting the impact of these inlining considerations.

Highlights

  • New Build Tuning Flag: Introduced a new --cfg zerocopy_inline_always flag to allow users to explicitly force #[inline(always)] on many of zerocopy's public functions.
  • Performance Optimization Alternative: This flag provides a narrowly-scoped alternative for improving the optimization of hot paths without incurring the broad build time penalties associated with codegen-units=1.
  • Conditional Inlining: Public methods within the TryFromBytes, FromBytes, and IntoBytes traits now conditionally apply #[inline(always)] when the zerocopy_inline_always cfg is enabled, otherwise defaulting to #[inline].
  • Benchmark Updates: Updated assembly and performance metrics for dynamic padding and dynamic size benchmarks, reflecting potential changes in code generation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@jswrenn jswrenn force-pushed the G750518420a745aec19276f7a24bcd0f66584bb2c branch from e77105c to 4b8fff9 Compare March 19, 2026 16:44
@jswrenn

jswrenn commented Mar 19, 2026

Copy link
Copy Markdown
Collaborator Author

@korran, this is a more general solution to the problem you're addressing in #3137. Curious to hear if you think it'd be useful to you!

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini is experiencing higher than usual traffic and was unable to create the review. Please try again in a few hours by commenting /gemini review.

@jswrenn jswrenn force-pushed the G750518420a745aec19276f7a24bcd0f66584bb2c branch from 4b8fff9 to c9a374e Compare March 19, 2026 16:47
@codecov-commenter

codecov-commenter commented Mar 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.85%. Comparing base (0406c5c) to head (b19e71c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3139   +/-   ##
=======================================
  Coverage   91.85%   91.85%           
=======================================
  Files          20       20           
  Lines        6067     6067           
=======================================
  Hits         5573     5573           
  Misses        494      494           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread README.md
@jswrenn jswrenn force-pushed the G750518420a745aec19276f7a24bcd0f66584bb2c branch 2 times, most recently from 165c805 to d8bb9f9 Compare March 20, 2026 17:30
Enables customers to tune inlining aggressiveness of many of zerocopy's
public functions. At higher `codegen-units`, the Rust compiler may fail
to inline invocations of conversion functions. Applying the
`#[inline(always)]` attribute (as in #3137) forces inlining, but that
might not be desirable for all monomorphizations or invocations.
Dynamically padded types, for instance, require much more complex
codegen than statically sized for unpadded dynamically sized types.

While reducing `codegen-units` for a build can improve codegen, it
carries a large penalty in build times. The `--cfg zerocopy_inline_always`
flag provides a narrowly-scoped lever for achieving some of the
benefits of `codegen-units=1` without the broad build time penalties.

gherrit-pr-id: G750518420a745aec19276f7a24bcd0f66584bb2c
@jswrenn jswrenn force-pushed the G750518420a745aec19276f7a24bcd0f66584bb2c branch from d8bb9f9 to b19e71c Compare March 20, 2026 17:37
@joshlf joshlf added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit a5f7fa1 Mar 20, 2026
108 checks passed
@joshlf joshlf deleted the G750518420a745aec19276f7a24bcd0f66584bb2c branch March 20, 2026 18:24
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.

3 participants