Repository navigation
[zerocopy] Split endian and sized-DST Kani proofs - #3981
Merged
Merged
Conversation
Two Kani proofs in `zerocopy` construct unnecessarily large CBMC SAT instances: 1. `layout::proofs::prove_dst_layout_pad_to_align_sized` generates an arbitrary `DstLayout` via `any_valid_dst_layout` and discards the `SizeInfo::SliceDst` variant with `kani::assume(false)`. Because CBMC merges control-flow paths before solving rather than pruning infeasible branches eagerly, it still bit-blasts the entire `TrailingSliceLayout` minimum-size alignment formula into CNF. Add `any_valid_sized_dst_layout` with the identical `SizeInfo::Sized` bounds (`size <= DstLayout::MAX_SIZE` and `Layout::from_size_align(size, align.get()).is_ok()`) and call it directly from `prove_dst_layout_pad_to_align_sized`. 2. `byteorder::tests::test_endian` inlines round-trip checks across all 12 unsigned, signed, and IEEE-754 floating-point byte-order types in both native and non-native endianness into one harness, producing a single >5 GiB CBMC goto-program. Keep the unified `#[test]` entry point for `cargo test` and Miri, and split the `#[cfg(kani)]` proof into `test_endian_unsigned`, `test_endian_signed`, and `test_endian_float` sharing the same generic round-trip helper so each family is verified in an independent smaller CBMC instance. Agent-authored-by: AI agent acting on joshlf's behalf
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3981 +/- ##
=======================================
Coverage 92.99% 92.99%
=======================================
Files 16 16
Lines 2469 2469
=======================================
Hits 2296 2296
Misses 173 173 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
Authored by an AI agent acting on joshlf's behalf. Review Receipt
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Authored by an AI agent acting on joshlf's behalf.
Human review surface
zerocopy/src/layout.rs,zerocopy/src/byteorder.rs):any_valid_sized_dst_layoutinzerocopy/src/layout.rsenforcing the exact samesize <= DstLayout::MAX_SIZEandLayout::from_size_align(size, align.get()).is_ok()assumptions as theSizeInfo::Sizedarm ofany_valid_dst_layout, and switchedprove_dst_layout_pad_to_align_sizedto call it directly instead of constructing and assuming away theSizeInfo::SliceDstarm.#[cfg_attr(kani, kani::proof)] fn test_endianinzerocopy/src/byteorder.rsunder#[cfg(kani)]intotest_endian_unsigned,test_endian_signed, andtest_endian_floatcalling the sharedtest_endian_roundtriphelper overcall_for_unsigned_types!,call_for_signed_types!, andcall_for_float_types!(preserving exact 1:1 coverage across all 12 types and both endiannesses, and preserving#[cfg(test)] fn test_endianunchanged).none.Summary
Bottom PR of the CI performance optimization stack.
TrailingSliceLayoutminimum-size bit-blasting inprove_dst_layout_pad_to_align_sized, cutting Kani verification time for that harness from234.4sto21.5s(10.9xfaster).byteorder::tests::test_endianunder#[cfg(kani)]into three per-family proofs (unsigned,signed,float), cutting peak CBMC memory from5,251 MBto1,865 MB(2.8xlower RSS) and reducing parallel verification latency from129.1sto35.0s(3.7xfaster under-j 4).