Minor optimizations to the Data Plane Computation #286
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.
Simplify implementation of PrefixSpace#getAddressBits using helper methods and the fact that BitSet is already an array of longs under the hood.
Save a lookup in PrefixSpace#containsPrefix.
Since the
SortedSet<Integer>
insideAsPath
are never changed, make themImmutableSortedSet
under the hood. The key advantage of this is to save on copies:ImmutableSortedSet.copyOf(set)
is a no-op ifset
is already anImmutableSortedSet
.Combined, the two optimizations shave about 20% off of one large network data plane computation (8m13s [493s] down to 6m41s [401s]).
It took me a long time to convince myself that the sets inside of
AsPath
aren't changed (and frankly, I may be wrong – but the tests pass). We would do well to add some proper Java abstractions here; based on what we do to these AsPaths in practice, it may expose other opportunities for improvement.