perf: List off-lock IO + DeleteAll shared /proc scan#60
Merged
Conversation
c9ac559 to
85a0da8
Compare
- Backend.List captures VMRecord snapshots under the DB lock then runs ToVM (which reads pidfile + stat vsock socket) outside the lock. Concurrent writers no longer queue behind status polls. - utils.ScanProcsByBinary walks /proc once and returns a cache; the per-call FindVMMByCmdline becomes a thin wrapper. DeleteAll calls ScanProcsByBinary up-front and reuses the scan via ProcScan.Find for each VM — N walks of /proc collapse to 1. - Non-linux stubs added for ProcScan / ScanProcsByBinary so darwin build stays green.
85a0da8 to
109765e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
2 perf wins from the final master audit. Net +51 LOC (mostly the new ProcScan API).
Backend.Listoff-lock IO (Q+E Replace bridge with TC redirect for VM networking #2):Listpreviously held the DB read lock whileToVMdidReadPIDFile+vsockBound/os.Statper running VM — N file syscalls × DB-lock-held, blocking concurrent writers. New shape: snapshot*VMRecordcopies under the lock, then runToVMoutside.utils.ScanProcsByBinarycache (Q+E support bridge tap to reduce hop between tap & nic #19):FindVMMByCmdlinewalks all of/procper call;DeleteAllinvokes it once per VM, so batchvm rmof N VMs scans/procN times. NewProcScanwalks once, callers callFind(sockPath)per id to filter the cached cmdlines.FindVMMByCmdlineis preserved as a one-shot wrapper for single-VM callers (WithRunningVM). Non-linux stubs added.Skipped from the audit:
ForEachVM's parallel collect contract and rewriting deletion failure semantics; not worth the risk for typical batch sizes (< 5 VMs).Based on
refactor/dedup-helpers(PR #59) to avoidhypervisor/inspect.goconflict.Test plan
make fmt-check && make lint && go test -race ./...— 21 packages green, lint 0, fmt 0GOOS=linux go build ./...— non-linux stubs verified