bgpkit-parser
bgpkit-parser copied to clipboard
Performance Improvements
The aim of this pull request is to improve overall parsing performance. These changes have largely been motivated by profiles conducted using Intel VTune, statistics on the general arrangement of MRT records collected using https://github.com/jmeggitt/bgp_attribute_survey, the new mrt_type benchmark, and personal intuition regarding performance.
Most of these changes are related to allocation and #85 .
Despite being quite lengthy, this pull request is not complete as there are still a couple of areas I want to get to. Particularly, I would like to make an AttributesStorage type which allows inlining some of the most common attribute groups. I will update this description with additional details on what/why various things are being done when this draft is converted to a regular pull request.
Currently, these changes improve performance by roughly ~2x as shown by the mrt_type benchmark.
Blocked by #123 and #124 .
Due to the size of these changes, it may be better to split the AsPath storage into its own pull request.
In fact, considering the amount of code added to AsPath across the most recent pull requests, it may even be worth considering turning it into its own crate.
Due to the size of these changes, it may be better to split the
AsPathstorage into its own pull request.In fact, considering the amount of code added to
AsPathacross the most recent pull requests, it may even be worth considering turning it into its own crate.
I'm fine with this PR size. Not sure about separating it into its own crate though. Users can use this crate without default parser feature to get only the bgp module, which should be sufficient.
EDIT: Added back in PR #127
Can we add back the previously available .to_u32_vec function? Or you've added something equivalent to quickly get a Vec
Something like this:
pub fn to_u32_vec(&self) -> Option<Vec<u32>> {
match self.segments.last() {
Some(AsPathSegment::AsSequence(v)) => Some(v.iter().map(|asn| (*asn).into()).collect()),
_ => None,
}
}