engine/vlan.js: the array-keyed member cache never hits when allowedVlans is a sliced copy (blocks #1749) #1809
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge#1809
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Why this issue exists. PR #1749 is the only open PR and cannot go green: three CI legs fail one assertion in its own new suite. Four rounds of diagnosis on the PR agree on the cause, which lives in
engine/- not in the PR's data, and not in a place the surgery loop may edit. This issue exists so the fix lands as its own change instead of as an amendment to a stale PR.Symptom.
test/trunk-allowed-remove-from-all.test.js:167- 2,000classifyEgress()calls against a 4,089-id allowed list (the shapeswitchport trunk allowed vlan remove 2on a default trunk produces). Bound isms < 3000.bc747907: 1,464 / 1,544 / 1,600 ms (green)PF_TEST_CONCURRENCY=10: 6,063-6,510 ms (red on Node 18/20/22, run 4759 and earlier)Cause - one line.
normalizePortConfig()buildsallowedVlansasraw.allowedVlans.slice(), so every call returns a new array object.engine/vlan.jskeys its membership cache (memberCache) on the array itself; a fresh identity every call means the cache is written and never read, and eachvlanListIncludes()falls back to a linear scan of ~4,089 ids.Measured on
bc747907, same host:So ~99% of the cost is the cache miss, not the copy.
Fix direction (engine owner's call, not prescribed here): make the cache survive a copy - key it on a stable identity/normalised form, or store a precomputed
Set/sorted array alongsideallowedVlansinnormalizePortConfig()so it travels with the sliced copy. Anything that keeps the per-frame lookup off the linear scan is enough; the bound in #1749's test is a symptom, and relaxing it to ~8 s would hide a real 60x regression on main.Why not just loosen the bound in #1749: the same path is
2466 msonorigin/maintoday, i.e. already close to the bound for one trunk; the cache is the bug.Once this lands, #1749 rebases onto it (its auto-rebase workflow is armed) and the queue drains.
switchport trunk allowed vlan removeon a default trunk subtracts, and a list prints as ranges #1749Measurement from the branch that this issue blocks
I ran the whole suite on #1749's head (
bc747907) in a scratch worktree, and it is green on a dev host:So
test/trunk-allowed-remove-from-all.test.jsis not red here, and the 99 red test legs since 22:27 are not "the branch's own test file being wrong". The one assertion in that file that can go red is a wall-clock bound, and it is marginal:test/trunk-allowed-remove-from-all.test.js:164-167— 2,000classifyEgresscalls against the materialised long list,ok(ms < 3000, ...).Measured on this host with
allowedVlansat its 4,089 ids (switchport trunk allowed vlan remove 2, then the same loop as the test):41% of budget on an idle machine. A runner leg that is ~2.5x slower or shared with another job crosses it; that is the shape of a failure that reproduces on all three legs and never on a laptop.
Why this issue is the fix, not a looser bound
The 1.2 s is exactly the cache miss described above:
allowedVlansisslice()d, the member cache is keyed by the array, so every one of the 2,000 frames re-scans 4,089 ids. With the cache hitting, the same loop is ~0.1 ms and the 3,000 ms bound stops being reachable at all — no test change needed.Consequence while it is open
#1749 is deadlocked, not stalled:
checks_failed()in.forgejo/workflows/auto-rebase.yml(#1789) now skips it, so it never gets rebased, so it stays 24 commits behindmain(d39b7a87is the merge base) and its head never changes. Land this engine fix and the next leg should be green on its own; nothing else is holding that PR.Not confirmed: which step each leg failed in — this Forgejo build exposes no job-log endpoint (
/actions/runs/<n>/jobs/<n>/logs→ 404), so the leg-level cause above is inference from a green local run plus the only wall-clock assertion in the tree.switchport trunk allowed vlan removeon a default trunk subtracts, and a list prints as ranges #1749