Skip to content
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

Minor optimizations to the Data Plane Computation #286

Merged
merged 4 commits into from
Aug 10, 2017

Conversation

dhalperi
Copy link
Member

@dhalperi dhalperi commented Aug 3, 2017

  1. Simplify implementation of PrefixSpace#getAddressBits using helper methods and the fact that BitSet is already an array of longs under the hood.

  2. Save a lookup in PrefixSpace#containsPrefix.

  3. Since the SortedSet<Integer> inside AsPath are never changed, make them ImmutableSortedSet under the hood. The key advantage of this is to save on copies: ImmutableSortedSet.copyOf(set) is a no-op if set is already an ImmutableSortedSet.

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.

Also comment it and test it.
… changed

This enables shallow copying, saving a significant amount of RAM and CPU
in data plane computation for large networks.
Since the map we're looking into is a ConcurrentHashMap, this actually
saves a significant amount of work.
@ratulm
Copy link
Member

ratulm commented Aug 3, 2017

Looks good to me. Probably best to have @arifogel's eyes on it too.

@dhalperi
Copy link
Member Author

dhalperi commented Aug 3, 2017

Yes, will not merge until @arifogel gets back.

Copy link
Member

@arifogel arifogel left a comment

Choose a reason for hiding this comment

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

Since nothing broke and this is empirically faster, I am approving.

@arifogel arifogel merged commit 5ed0deb into batfish:master Aug 10, 2017
@dhalperi dhalperi deleted the optimize branch August 10, 2017 21:57
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.

None yet

3 participants