Commit a94d548
northd: Avoid useless iterations when recomputing policies.
When recomputing router policies we can just mark everything that we
already had as "potentially stale", build the new set of parsed policies
and then remove what actually is stale in one go for all router datapaths.
The old code was achieving the same thing but in a very inefficient way.
It used to:
- walk all routers, for each router R:
- walk all parsed policies (for all routers) and mark as potentially
stale the ones that correspond to R
- reparse R's policies (making the ones that are still relevant "not
stale")
- remove all actually stale policies for R
But that means O(N x M) iterations, where N is the number of routers and
M is the number of router policies in the NB database.
But it turns out we never had any stale policies because we always do a
recompute of the route_policies node. So we can remove all the stale
checking and looking up of parsed routes.
This makes it that we can rebuild the parsed policies in a single pass,
with a complexity of O(M).
Some test numbers from a scaled setup, 1.6K routers with a total number
of 4.8K policies:
Before:
node: route_policies, recompute (forced) took 254ms
After:
node: route_policies, recompute (forced) took 6ms
Fixes: 15c9c9f ("northd: Add bfd, static_routes, route_policies and bfd_sync nodes to I-P engine.")
Reported-at: https://redhat.atlassian.net/browse/FDP-3996
Assisted-by: Claude Opus 4.6, Claude Code
Acked-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
(cherry picked from commit 24ed825)1 parent ca0dd14 commit a94d548
2 files changed
Lines changed: 0 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14356 | 14356 | | |
14357 | 14357 | | |
14358 | 14358 | | |
14359 | | - | |
14360 | | - | |
14361 | | - | |
14362 | | - | |
14363 | | - | |
14364 | | - | |
14365 | 14359 | | |
14366 | 14360 | | |
14367 | 14361 | | |
| |||
14441 | 14435 | | |
14442 | 14436 | | |
14443 | 14437 | | |
14444 | | - | |
14445 | 14438 | | |
14446 | 14439 | | |
14447 | 14440 | | |
| |||
14450 | 14443 | | |
14451 | 14444 | | |
14452 | 14445 | | |
14453 | | - | |
14454 | 14446 | | |
14455 | 14447 | | |
14456 | 14448 | | |
14457 | 14449 | | |
14458 | | - | |
14459 | | - | |
14460 | | - | |
14461 | | - | |
14462 | | - | |
14463 | | - | |
14464 | | - | |
14465 | | - | |
14466 | | - | |
14467 | | - | |
14468 | 14450 | | |
14469 | 14451 | | |
14470 | 14452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
196 | | - | |
197 | 195 | | |
198 | 196 | | |
199 | 197 | | |
| |||
0 commit comments