-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RibDelta optimizations #6245
RibDelta optimizations #6245
Conversation
Previously RibDelta._actions was a sorted map from Prefix to list of advertisements for that prefix. The only use of the map was to efficiently retrieve the keyset for getPrefixes. However, getPrefixes is called at most once, and often 0 times. So we should only pay to collect and dedup the prefixes if it's called.
Particularly in hot code. The builder allocates a linked hash map, copies all the advertisements in, and then copies them out to a list on build.
Codecov Report
@@ Coverage Diff @@
## master #6245 +/- ##
============================================
- Coverage 72.98% 72.97% -0.02%
- Complexity 35119 35120 +1
============================================
Files 2837 2837
Lines 142729 142742 +13
Branches 17122 17129 +7
============================================
- Hits 104176 104159 -17
- Misses 30318 30337 +19
- Partials 8235 8246 +11
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 7 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @anothermattbrown and @progwriter)
projects/batfish/src/main/java/org/batfish/dataplane/rib/RibDelta.java, line 51 at r2 (raw file):
*/ public static <R extends AbstractRouteDecorator> RibDelta<R> adding(Collection<R> routes) { return new RibDelta<>(
Should we initialize a builder with size instead? Will save in intermediate allocations. builderWithExpectedSize
projects/batfish/src/main/java/org/batfish/dataplane/rib/RibDelta.java, line 126 at r2 (raw file):
@SuppressWarnings("PMD.LooseCoupling") // insertion order matters
FYI this one
projects/batfish/src/main/java/org/batfish/dataplane/rib/RibDelta.java, line 136 at r2 (raw file):
private Map<R, RouteAdvertisement<R>> _actions;
FWIW, in prior iterations of this code I preferred the supresswarnings of PMD.LooseCoupling and keeping explicit type signature. I commented at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @anothermattbrown and @progwriter)
projects/batfish/src/main/java/org/batfish/dataplane/rib/RibDelta.java, line 51 at r2 (raw file):
Previously, dhalperi (Dan Halperin) wrote…
Should we initialize a builder with size instead? Will save in intermediate allocations. builderWithExpectedSize
counterpoint: we could confirm whether the collector takes advantage of this.
projects/batfish/src/main/java/org/batfish/dataplane/rib/RibDelta.java, line 51 at r2 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Anti-counter-point: it does not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @progwriter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @progwriter)
flatten actions
Previously RibDelta._actions was a sorted map from Prefix to list of
advertisements for that prefix. The only use of the map was to
efficiently retrieve the keyset for getPrefixes. However, getPrefixes
is called at most once, and often 0 times. So we should only pay to
collect and dedup the prefixes if it's called.
avoid using Builders when possible
Particularly in hot code. The builder allocates a linked hash map,
copies all the advertisements in, and then copies them out to a list
on build.