Repository navigation
perf(elem): cut copies and allocations from MRT update to elems - #348
Merged
Merged
Conversation
- ElemIterator yields elems per record instead of collecting a Vec - the last announced elem takes the shared attributes instead of cloning them - attribute values are moved out in place, not copied by value - parse_attributes clones attribute bytes only when parsing fails into_elem_iter: -24% on updates, -21% on RIB dumps. A new `updates elementor record_to_elems_iter` benchmark times record-to-elem conversion alone: -22%. Assisted-by: Claude Code
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #348 +/- ##
==========================================
- Coverage 92.05% 92.04% -0.02%
==========================================
Files 96 96
Lines 23396 23396
==========================================
- Hits 21537 21534 -3
- Misses 1859 1862 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Static review supports preserved behavior and focused regression coverage, though tests and benchmarks were not executed.
Review effort: Balanced
Findings: None
What changed in this PR
Reduces copying and allocation overhead when converting MRT records into BGP elements, while preserving output behavior.
Changes:
- Streams elements per record instead of collecting intermediate vectors.
- Moves shared attributes where possible and avoids unnecessary byte clones.
- Adds focused regression tests and a conversion-only benchmark.
| File | Description |
|---|---|
| src/parser/mrt/mrt_elem.rs | Adds pending-element iteration, ownership optimizations, and regression tests. |
| src/parser/iters/default.rs | Replaces cached element vectors with streaming iteration. |
| src/parser/bgp/attributes/mod.rs | Avoids upfront byte clones while preserving malformed attributes. |
| CHANGELOG.md | Documents reported conversion speedups. |
| benches/internals.rs | Adds an isolated record-to-element benchmark. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
A performance improvement. The change in performance varies a bit between an Intel i7 14700 machine and a M2 MacBook Pro.
Summary of the change. These numbers are not from a fully idle machine, so I do not think the regressions are real. Would be good to re-run
cargo benchthough.into_elem_iter: -24% on updates, -21% on RIB dumps. A new
updates elementor record_to_elems_iterbenchmark times record-to-elem conversion alone: -22%.Assisted-by: Claude Code