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

Removed freezing for RIBs #665

Merged
merged 1 commit into from
Nov 15, 2017
Merged

Removed freezing for RIBs #665

merged 1 commit into from
Nov 15, 2017

Conversation

progwriter
Copy link
Contributor

@progwriter progwriter commented Nov 11, 2017

Now RIBs keep an up-to-date collection of all routes. Fixes #646


This change is Reviewable

*/
public void freeze() {
_finalRoutes = Collections.unmodifiableSet(getRoutes());
return _allRoutes;
Copy link
Member

Choose a reason for hiding this comment

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

What is the expected semantics of the return value here?

Questions:

  1. Should clients be able to modify the return value?
  2. Should clients see updated values if this AbstractRib is modified later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. They should not.
  2. Good question. I believe the answer here is also no since we use getRoutes to iterate over a particular snapshot of the RIB.

@dhalperi
Copy link
Member

Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion.


projects/batfish/src/main/java/org/batfish/bdp/AbstractRib.java, line 443 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…
  1. They should not.
  2. Good question. I believe the answer here is also no since we use getRoutes to iterate over a particular snapshot of the RIB.

So it sounds like we either need to return a Collections.unmodifiableList or an ImmutableList.

Or figure out the combination of memoizing + access pattern that makes this work out?


Comments from Reviewable


public AbstractRib(VirtualRouter owner) {
_tree = new RibTree();
_owner = owner;
_finalRoutes = null;
_allRoutes = new TreeSet<>();
Copy link
Member

Choose a reason for hiding this comment

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

why not ImmutableSet.of();?

@dhalperi
Copy link
Member

Minor comments, but :lgtm:


Reviewed 3 of 4 files at r1, 2 of 2 files at r2.
Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


projects/batfish/src/main/java/org/batfish/bdp/AbstractRib.java, line 213 at r2 (raw file):

    /**
     * Add the route to the set of routes at this node

I feel like this function adds questionable value over the 5 places it was used, but okay :)


projects/batfish/src/test/java/org/batfish/bdp/AbstractRibTest.java, line 212 at r2 (raw file):

    // Add completely new route and check that the size increases
    rib.mergeRoute(new OspfIntraAreaRoute(new Prefix("2.2.2.2/32"), null, 100, 30, 1));
    assertThat(rib.getRoutes(), hasSize(2));

We should test the invariants we agreed upon in the PR discussion.

  1. if I get routes, I can't modify the result.
  2. if I get routes, then modify the RIB, the routes I previously got did not change.

and probably also

  1. if I get routes, then don't modify and get again, I should get actually the same object. (assertThat(rib.getRoutes(), is(prev)) for example).

(each in its own unit test).


Comments from Reviewable

@dhalperi
Copy link
Member

Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


Comments from Reviewable

@dhalperi
Copy link
Member

I played with this last night and it seemed to shave something like a minute (out of 6.5 mins) off of building a real data plane. Nice.


Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


Comments from Reviewable

…f routes

- Set obtained from getRoutes() is now an immutable set
- Set obtained from getRoutes() does not reflect subsequent changed to the RIB (not a view)
- Each call to getRoutes returns the same set, if the RIB has not been modified (performance improvement)
- Added tests that enforce semantics described above
@dhalperi
Copy link
Member

Reviewed 4 of 4 files at r4.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@dhalperi dhalperi merged commit 278d4e9 into master Nov 15, 2017
@dhalperi dhalperi deleted the noribfreeze branch November 15, 2017 19:39
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

2 participants