Skip to content

Fix TryFromBytes::try_read_from* - #3712

Open
jswrenn wants to merge 3 commits into
mainfrom
G35c8b8db33f4c984d5716af9a26c0a5ec9bd9c7e
Open

jswrenn wants to merge 3 commits into
mainfrom
G35c8b8db33f4c984d5716af9a26c0a5ec9bd9c7e

Conversation

@jswrenn

@jswrenn jswrenn commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Refactors these routines to not depend on padding byte preservation
across moves. Along the way, we make the try_read_from helper safe,
generic, and better-optimized. Instruction counts for the
try_read_from_* change by -36% to -55%.


Latest Update: v3 — Compare vs v2

📚 Full Patch History

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

Version v2 v1 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/G35c8b8db33f4c984d5716af9a26c0a5ec9bd9c7e && git checkout -b pr-G35c8b8db33f4c984d5716af9a26c0a5ec9bd9c7e FETCH_HEAD

Checkout

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

Cherry Pick

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

Pull

git pull origin refs/heads/G35c8b8db33f4c984d5716af9a26c0a5ec9bd9c7e

Stacked PRs enabled by GHerrit.

gherrit-pr-id: Gfa0cb30780189c43bb84da57a9ade4d5a9754223
...so that they consume an `IntoBytes` as their source. Since these
methods are private, this does not yet increase expressivity for
users, but nonetheless allows the compiler to better optimize existing
callsites. For example, the `ref_from_prefix_dynamic_size` benchmark
becomes branchless, shrinking from 14 to 9 instructions. The falible
suffix-with-elems benchmarks shrink from 24 to 17 instructions for
dynamic size, and 28 to 20 instructions for dynamic padding. Only
`try_ref_from_prefix_dynamic_size` regresses, from 19 to 20 instructions.

gherrit-pr-id: Gd1b460a8ec2e8aa8adf2e070c329d9f209c7c89c
@codecov-commenter

codecov-commenter commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.64%. Comparing base (714c822) to head (d4c0f5e).

Additional details and impacted files
@@                              Coverage Diff                              @@
##           Gd1b460a8ec2e8aa8adf2e070c329d9f209c7c89c    #3712      +/-   ##
=============================================================================
+ Coverage                                      92.51%   92.64%   +0.12%     
=============================================================================
  Files                                             20       20              
  Lines                                           6362     6429      +67     
=============================================================================
+ Hits                                            5886     5956      +70     
+ Misses                                           476      473       -3     

☔ View full report in Codecov by Harness.
📢 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.

@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: 12bc48fa9b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread zerocopy/src/lib.rs Outdated
Comment thread zerocopy/src/lib.rs Outdated
Refactors these routines to not depend on padding byte preservation
across moves. Along the way, we make the `try_read_from` helper safe,
generic, and better-optimized. Instruction counts for the
`try_read_from_*` change by -36% to -55%.

gherrit-pr-id: G35c8b8db33f4c984d5716af9a26c0a5ec9bd9c7e
Comment thread zerocopy/src/lib.rs
Base automatically changed from Gd1b460a8ec2e8aa8adf2e070c329d9f209c7c89c to main September 24, 2026 01:33

This branch has not been deployed

No deployments
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