Use zerocopy for mrt header parsing#263
Conversation
6292647 to
6ee084c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #263 +/- ##
==========================================
- Coverage 91.23% 91.09% -0.14%
==========================================
Files 83 83
Lines 14939 14974 +35
==========================================
+ Hits 13630 13641 +11
- Misses 1309 1333 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates MRT common-header parsing/encoding to use zerocopy for struct-based, big-endian field access, aiming to reduce per-field cursor reads and simplify on-wire layout handling.
Changes:
- Introduce
RawMrtCommonHeader/RawMrtEtCommonHeaderon-wire structs and parse viazerocopy. - Update
CommonHeader::encode()to serialize via the same raw header structs. - Add Criterion benchmarks for
into_raw_record_iteron updates and RIB inputs; add optionalzerocopydependency behind theparserfeature.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/parser/mrt/mrt_header.rs |
Switch MRT header parsing/encoding to zerocopy-backed raw structs; adjust ET handling to build combined header bytes without BytesMut. |
benches/internals.rs |
Add benchmark cases for into_raw_record_iter on updates and RIB datasets. |
Cargo.toml |
Add optional zerocopy dependency and include it in the parser feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const _: () = assert!(size_of::<RawMrtCommonHeader>() == 12); | ||
|
|
There was a problem hiding this comment.
size_of is used in the const assertions but isn’t imported or fully qualified, which will fail to compile. Import core::mem::size_of/std::mem::size_of (or change these calls to core::mem::size_of::<...>()).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
90f7029 to
96a948f
Compare
Use zerocopy for parsing the MRT header. This potentially saves a number of read syscalls. Personally I also think the pattern is quite readable for parsing structs from the wire.