Skip to content

perf: optimize batch policy removal#1729

Open
huynhanx03 wants to merge 1 commit intoapache:masterfrom
huynhanx03:master
Open

perf: optimize batch policy removal#1729
huynhanx03 wants to merge 1 commit intoapache:masterfrom
huynhanx03:master

Conversation

@huynhanx03
Copy link
Copy Markdown

Overview

Optimize batch policy removal by rebuilding Policy and PolicyMap once in RemovePoliciesWithAffected. The previous implementation removed each rule one by one and updated policy indexes after every deletion, which becomes expensive for large batch removals.

Change

  • Remove policies in batch by collecting keys, compacting Policy, and rebuilding PolicyMap once.
  • Add BenchmarkRemovePoliciesLarge to cover batch removal performance.

Benchmark

goos:  darwin
goarch: arm64
cpu:   Apple M1

BenchmarkRemovePoliciesLarge
metric      old       new      delta
ns/op       481,529   14,657   -97.0%
B/op        155,938   12,660   -91.9%
allocs/op   5,159     207      -96.0%

Signed-off-by: huynhanx03 <157712338+huynhanx03@users.noreply.github.com>
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.

1 participant