vlan: answer membership questions without re-parsing an allowed list (#1809) #1812
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1812
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/1117-0805"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1809.
What was wrong.
switchport trunk allowed vlan remove 2on a default trunk leaves 4,089 ids inallowedVlans.classifyEgress()normalises the port config and then asksvlanListIncludes()about one id � and both calls ran the fullparseVlanList()tokeniser (string conversion, regex per entry, sort) over the whole array. One bit of information cost ~1.3 ms, so 2,000 calls took 2,445 ms locally; #1749 measured 6,063-6,510 ms in CI atPF_TEST_CONCURRENCY=10.The issue names an identity-keyed
memberCache; there is no such cache onmain� the cost is the two unconditional parses per call, which is the same defect and wants the same fix: stop re-deriving a list that is already in canonical form.What changed (
engine/vlan.js, no exported surface changed):isCanonicalVlanArray()recognises a list whose entries are integers, in range, none of the reserved block, strictly ascending � i.e. exactly whatparseVlanList()would return for it. One pass of integer comparisons.normalizePortConfig()copies such a list instead of parsing it. The copy is kept, so the returned config still owns its array and a caller cannot edit the input through it.vlanListIncludes()binary-searches such a list instead of parsing it.'all'� still goes throughparseVlanList()and keeps its exact meaning.Measured (same host, 4,089 ids): 2,445 ms ? 35 ms for 2,000
classifyEgress()calls; 37-58 ms across ten concurrent processes.Tests. New
test/vlan-membership-lookup.test.js, 18 assertions: the fast path agrees with a full parse for every id 1-4094, non-canonical lists keep their parsed meaning,normalizePortConfig()copies rather than aliases, and the 2,000-call bound (#1749 uses 3,000 ms; this asserts 1,500 ms).Gates:
node scripts/syntax-check.js380 files OK;check-control-bytesclean; fullnpm test309 suites, 10,776 assertions, 0 failed.Once merged, #1749 should go green on rebase � its data is not the problem.
Co-authored-by: Hermes Agent jay@jayw.uk
switchport trunk allowed vlan removeon a default trunk subtracts, and a list prints as ranges #1749