Skip to content

Conversation

@digizeph
Copy link
Member

@digizeph digizeph commented Dec 7, 2025

This pull request introduces a new intermediate data structure, MrtUpdate, and associated iterators to the BGPKit parser, providing a more efficient way to process BGP announcements. It updates documentation, benchmarks, and examples to reflect and demonstrate these new capabilities. The changes are grouped below by theme.

New Features and API Additions

  • Added UpdateIterator and FallibleUpdateIterator for iterating over BGP announcements, with the new MrtUpdate enum supporting both BGP4MP UPDATE messages and TableDumpV2 RIB entries. Also introduced Bgp4MpUpdate and TableDumpV2Entry structs, and new methods (into_update_iter, into_fallible_update_iter) on BgpkitParser for efficient batch processing. [1] [2]

Documentation and Examples

  • Updated README.md, crate-level docs (src/lib.rs), and changelog to describe the new MrtUpdate representation, compare it to existing approaches, and clarify memory/performance trade-offs. Added a new example (examples/update_messages_iter.rs) to demonstrate usage and performance comparison.

Benchmarking

  • Added new benchmarks for into_update_iter on both updates and rib dump files to measure and compare performance with existing iterators. [1] [2]

These changes enhance the parser's flexibility and efficiency, making it easier to choose the right data structure for different BGP analysis tasks.

Add MrtUpdate enum plus Bgp4MpUpdate and TableDumpV2Entry structs and
BgpkitParser::into_update_iter() and into_fallible_update_iter() to
iterate BGP4MP UPDATEs and TableDumpV2 RIB entries. Include example,
tests and a benchmark.
@digizeph
Copy link
Member Author

digizeph commented Dec 7, 2025

This addresses issue #250

@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

❌ Patch coverage is 75.38803% with 111 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.50%. Comparing base (0453969) to head (e504b54).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/parser/iters/update.rs 81.06% 78 Missing ⚠️
src/parser/iters/mod.rs 15.38% 33 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #254      +/-   ##
==========================================
- Coverage   90.87%   90.50%   -0.37%     
==========================================
  Files          80       81       +1     
  Lines       12588    13006     +418     
==========================================
+ Hits        11439    11771     +332     
- Misses       1149     1235      +86     

☔ 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a new intermediate data structure MrtUpdate and associated iterators (UpdateIterator and FallibleUpdateIterator) to the BGPKit parser. This provides a middle ground between the low-level MrtRecord and high-level BgpElem representations, optimizing for cases where per-prefix attribute duplication is unnecessary. The change enhances the parser's flexibility and performance for batch processing of BGP announcements without expanding them into individual per-prefix elements.

Key changes:

  • New MrtUpdate enum with variants for BGP4MP updates, TableDumpV2 RIB entries, and legacy TableDump messages
  • Two new iterator types: UpdateIterator (error-skipping) and FallibleUpdateIterator (error-exposing)
  • Comprehensive documentation and examples demonstrating the performance benefits

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/parser/iters/update.rs Core implementation of the new iterator types, data structures (Bgp4MpUpdate, TableDumpV2Entry, MrtUpdate), and error handling logic
src/parser/iters/mod.rs Integration of new iterators into the parser module, exposing into_update_iter() and into_fallible_update_iter() methods with documentation
src/lib.rs Updated crate-level documentation to describe the three-way data representation model and provide usage guidance
examples/update_messages_iter.rs New comprehensive example demonstrating UpdateIterator usage and comparing performance with ElemIterator
examples/README.md Added documentation entry for the new example
benches/internals.rs Added benchmarks for the new into_update_iter() method on both updates and RIB dump files
README.md Updated data representation documentation to include MrtUpdate in the three-way model
CHANGELOG.md Documented the new feature, structs, and methods in the unreleased section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

When core_dump is enabled, write available record bytes to mrt_core_dump
on parse errors. Also fix minor typos in CHANGELOG and examples README
@digizeph digizeph merged commit e335234 into main Dec 7, 2025
4 of 5 checks passed
@digizeph digizeph deleted the mrt-update-iterator branch December 7, 2025 23:41
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.

2 participants