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

RoutingPolicy: don't build deep unions #6433

Merged
merged 1 commit into from
Nov 17, 2020

Conversation

dhalperi
Copy link
Member

In very long routing policies, especially when they have lots of
continue statements, we might compile them into fairly complicated
structures with Call statements. Sets.union is a shallow operation that
never coalesces, so it seems plausible that building a deep union will
cause stack overflows on containment checks.

To fix this, materialize the sets as we go. This should not in practice
be very expensive unless we are in a case that would cause a stack
overflow with the prior approach.

In very long routing policies, especially when they have lots of
continue statements, we might compile them into fairly complicated
structures with Call statements. Sets.union is a shallow operation that
never coalesces, so it seems plausible that building a deep union will
cause stack overflows on containment checks.

To fix this, materialize the sets as we go. This should not in practice
be very expensive unless we are in a case that would cause a stack
overflow with the prior approach.
@batfish-bot
Copy link

This change is Reviewable

Copy link
Contributor

@progwriter progwriter left a 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 r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @anothermattbrown and @corinaminer)

@dhalperi
Copy link
Member Author

The bug reported by @dannypetrov took place on Arista with a route-map with 1146 terms.

@codecov
Copy link

codecov bot commented Nov 17, 2020

Codecov Report

Merging #6433 (6f85e1b) into master (55afb34) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #6433      +/-   ##
============================================
- Coverage     73.12%   73.10%   -0.02%     
- Complexity    35324    35343      +19     
============================================
  Files          2819     2820       +1     
  Lines        142996   143133     +137     
  Branches      17218    17233      +15     
============================================
+ Hits         104565   104640      +75     
- Misses        30168    30214      +46     
- Partials       8263     8279      +16     
Impacted Files Coverage Δ Complexity Δ
...atfish/datamodel/routing_policy/RoutingPolicy.java 94.31% <100.00%> (+0.27%) 30.00 <0.00> (ø)
...rg/batfish/identifiers/StorageBasedIdResolver.java 85.29% <0.00%> (-5.89%) 22.00% <0.00%> (ø%)
.../org/batfish/dataplane/rib/RouteAdvertisement.java 83.67% <0.00%> (-4.09%) 18.00% <0.00%> (-1.00%)
...col/src/main/java/org/batfish/role/InferRoles.java 89.54% <0.00%> (-1.37%) 50.00% <0.00%> (-1.00%)
...src/main/java/org/batfish/coordinator/PoolMgr.java 59.52% <0.00%> (-1.20%) 15.00% <0.00%> (-1.00%)
...ain/java/org/batfish/storage/FileBasedStorage.java 86.19% <0.00%> (-0.95%) 249.00% <0.00%> (ø%)
...g/batfish/representation/cisco_nxos/Interface.java 95.12% <0.00%> (-0.94%) 103.00% <0.00%> (+7.00%) ⬇️
...resentation/cisco_nxos/CiscoNxosConfiguration.java 87.41% <0.00%> (-0.77%) 366.00% <0.00%> (+9.00%) ⬇️
...java/org/batfish/dataplane/ibdp/VirtualRouter.java 90.54% <0.00%> (-0.34%) 208.00% <0.00%> (-1.00%)
...a/org/batfish/representation/aws/LoadBalancer.java 82.18% <0.00%> (-0.32%) 70.00% <0.00%> (-1.00%)
... and 5 more

@dhalperi dhalperi merged commit e6c67ab into batfish:master Nov 17, 2020
@dhalperi dhalperi deleted the routing-policy-union branch November 17, 2020 20:51
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