You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3cbab7e
Browse filesBrowse the repository at this point in the historyBrowse files
adapter/statsclient: read each symlink target once when refreshing a dir
VPP exposes some counters only as one vector plus a set of symlinks naming its
items. /node/errors is the case that hurts: it is a single counter vector, and
every /err/<node>/<reason> is a symlink into one item of it. A capture from a
live device has 4223 such symlinks over a 4223-item vector.
UpdateDir resolved each of those individually, and resolving a symlink reads its
whole backing vector - so refreshing a prepared dir over that fan re-read the
same vector 4223 times.
Group the symlinks in a prepared dir by the entry they alias, read each target
once, and fan its items out into the prepared entries. The fan-out writes
through the slices the entries already hold, so it does not allocate per
symlink, and it produces exactly the shape resolving each symlink would: one
value per worker thread. Anything the fan-out does not recognise falls back to
resolving that symlink on its own, as does segment v1, which has no symlink
target encoding.
This stays entirely inside statsclient. An earlier version of this change
exposed the (target, item) pair as a public ListSymlinks API so a caller could
read the vector and label its items itself; doing the grouping here gives the
same performance model with no API change at all, as suggested in review.
Two allocation sources found on the way, both paid per symlink per refresh:
storing the fanned-out slice back into the adapter.Stat interface boxed it, and
getSymlinkIndexes serialised the union through a bytes.Buffer to split one
uint64 into two uint32s. Refreshing 128 symlinks went from 654 allocations to
142 - the remainder being one name clone per prepared entry.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments