Skip to content

feat(table): extract communityAnyIndex and add fast match for ext-comms#3422

Closed
Ivan-Pokhabov wants to merge 1 commit into
osrg:masterfrom
Ivan-Pokhabov:feat/community-and-ext-comm-matcher-infra
Closed

feat(table): extract communityAnyIndex and add fast match for ext-comms#3422
Ivan-Pokhabov wants to merge 1 commit into
osrg:masterfrom
Ivan-Pokhabov:feat/community-and-ext-comm-matcher-infra

Conversation

@Ivan-Pokhabov
Copy link
Copy Markdown
Contributor

  • Rename communityLocalBitmap → localAdminBitmap and add receiver methods (isSet/set/or/fillAll) replacing four standalone functions
  • Extract communityAnyIndex (perAS, asnIndependent, hasRegexp) with matchesAny() method, replacing three separate fields on CommunitySet
  • buildCommunityMatcherBitmaps now returns communityAnyIndex directly
  • CommunityCondition.Evaluate() delegates fast path to anyIdx.matchesAny()

@Ivan-Pokhabov
Copy link
Copy Markdown
Contributor Author

Perf and fuzzing

➜  gobgp git:(feat/community-and-ext-comm-matcher-infra)✗ go test ./internal/pkg/table/... -run "FuzzExtCommunity" -fuzz=FuzzExtCommunityCondition -v    14:53:38
=== RUN   FuzzExtCommunityCondition
fuzz: elapsed: 0s, gathering baseline coverage: 0/618 completed
fuzz: elapsed: 1s, gathering baseline coverage: 618/618 completed, now fuzzing with 10 workers
fuzz: elapsed: 3s, execs: 59490 (19825/sec), new interesting: 5 (total: 623)
fuzz: elapsed: 6s, execs: 150131 (30213/sec), new interesting: 12 (total: 630)
fuzz: elapsed: 9s, execs: 241101 (30326/sec), new interesting: 26 (total: 644)
fuzz: elapsed: 12s, execs: 298600 (19161/sec), new interesting: 33 (total: 651)
fuzz: elapsed: 15s, execs: 355113 (18843/sec), new interesting: 40 (total: 658)
fuzz: elapsed: 18s, execs: 400748 (15213/sec), new interesting: 42 (total: 660)
fuzz: elapsed: 21s, execs: 443416 (14218/sec), new interesting: 46 (total: 664)
fuzz: elapsed: 24s, execs: 487368 (14651/sec), new interesting: 55 (total: 673)
fuzz: elapsed: 27s, execs: 535953 (16193/sec), new interesting: 58 (total: 676)
fuzz: elapsed: 30s, execs: 583499 (15833/sec), new interesting: 59 (total: 677)
fuzz: elapsed: 33s, execs: 626857 (14474/sec), new interesting: 63 (total: 681)
fuzz: elapsed: 36s, execs: 669707 (14283/sec), new interesting: 67 (total: 685)
fuzz: elapsed: 39s, execs: 715419 (15233/sec), new interesting: 70 (total: 688)
fuzz: elapsed: 42s, execs: 744468 (9686/sec), new interesting: 77 (total: 695)
fuzz: elapsed: 45s, execs: 760893 (5472/sec), new interesting: 78 (total: 696)
fuzz: elapsed: 48s, execs: 769052 (2720/sec), new interesting: 78 (total: 696)
fuzz: elapsed: 51s, execs: 777010 (2651/sec), new interesting: 78 (total: 696)
^Cfuzz: elapsed: 52s, execs: 779683 (2920/sec), new interesting: 79 (total: 697)
--- PASS: FuzzExtCommunityCondition (51.96s)
=== NAME
PASS
ok      github.com/osrg/gobgp/v4/internal/pkg/table     52.367s

➜  gobgp git:(feat/community-and-ext-comm-matcher-infra)✗ GOBGP_COMMUNITY_BENCH_COMPARE=1 go test ./internal/pkg/table/ -v -run 'TestExtCommunityConditionCompareSummary' -count=1 2>&1
=== RUN   TestExtCommunityConditionCompareSummary

[extended community]
bench           new ns/op  legacy ns/op  legacy/new  name
-----           ---------  -----------   --------    ----
rt9_exact_last  14         292           20.86x      RT / 9 exact patterns / last matches
rt9_exact_none  15         81            5.40x       RT / 9 exact patterns / no match
rt15_mix_exact  19         407           21.42x      RT / 15 patterns / wildcard prefix / exact RT match
rt15_mix_wild   20         139           6.95x       RT / 15 patterns / wildcard prefix / wildcard RT match
rt15_multi_3rt  19         919           48.37x      RT / 15 patterns / 3 RTs / early match
rt_local_digit  13         166           12.77x      RT / ^\d+:local / bitmap-style / match
rt_local_alt    13         174           13.38x      RT / ^\d+:(a|b) / bitmap-style / match
rt_local_miss   14         148           10.57x      RT / ^\d+:local / no match
--- PASS: TestExtCommunityConditionCompareSummary (22.54s)
PASS
ok      github.com/osrg/gobgp/v4/internal/pkg/table     24.057s

- Rename communityLocalBitmap → localAdminBitmap and add receiver
  methods (isSet/set/or/fillAll) replacing four standalone functions
- Extract communityAnyIndex (perAS, asnIndependent, hasRegexp) with
  matchesAny() method, replacing three separate fields on CommunitySet
- buildCommunityMatcherBitmaps now returns communityAnyIndex directly
- CommunityCondition.Evaluate() delegates fast path to anyIdx.matchesAny()
@Ivan-Pokhabov Ivan-Pokhabov force-pushed the feat/community-and-ext-comm-matcher-infra branch from 47267cc to a330b5c Compare May 15, 2026 22:26
@fujita
Copy link
Copy Markdown
Member

fujita commented May 24, 2026

Pushed, thanks.

@fujita fujita closed this May 24, 2026
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.

2 participants