-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve NetworkPolicy batch installation (#2479)
BatchInstallPolicyRuleFlows first generates all flows then installs them via single bundle. However, it generates the flows incrementally. If an address is shared by multiple rules, intermediate flows will be generated, for instance: expected flow: add "nw_dst=10.128.119.108 actions=conjunction(64,2/2),conjunction(65,2/2),conjunction(66,2/2)" actual flows: add "nw_dst=10.128.119.108 actions=conjunction(64,2/2)" mod "nw_dst=10.128.119.108 actions=conjunction(64,2/2),conjunction(65,2/2)" mod "nw_dst=10.128.119.108 actions=conjunction(64,2/2),conjunction(65,2/2),conjunction(66,2/2)" The number of flows for this address will be same as the number of the actions. The number of actual actions in these flows will be O(N^2), N=number of desired actions. This increases CPU and memory usage greatly in a high scale cluster. This patches optimizes it by generating flows based on final state, reducing the time and space complexity from O(N^2) to O(N). In same cluster, it's observed that the memory usage was reduced from 1.1G to 500M, the execution time was reduced from 10s to 2s. benchmark comparison: name old time/op new time/op delta BatchInstallPolicyRuleFlows-48 458ms ± 4% 169ms ± 1% -63.22% (p=0.008 n=5+5) name old alloc/op new alloc/op delta BatchInstallPolicyRuleFlows-48 205MB ± 0% 56MB ± 0% -72.47% (p=0.008 n=5+5) name old allocs/op new allocs/op delta BatchInstallPolicyRuleFlows-48 4.29M ± 0% 0.92M ± 0% -78.60% (p=0.008 n=5+5) Signed-off-by: Quan Tian <qtian@vmware.com>
- Loading branch information
Showing
5 changed files
with
450 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.