Skip to content

perf: List off-lock IO + DeleteAll shared /proc scan#60

Merged
CMGS merged 1 commit into
masterfrom
perf/batch-tx-and-cache
May 20, 2026
Merged

perf: List off-lock IO + DeleteAll shared /proc scan#60
CMGS merged 1 commit into
masterfrom
perf/batch-tx-and-cache

Conversation

@CMGS
Copy link
Copy Markdown
Contributor

@CMGS CMGS commented May 20, 2026

Summary

2 perf wins from the final master audit. Net +51 LOC (mostly the new ProcScan API).

  • Backend.List off-lock IO (Q+E Replace bridge with TC redirect for VM networking #2): List previously held the DB read lock while ToVM did ReadPIDFile + vsockBound/os.Stat per running VM — N file syscalls × DB-lock-held, blocking concurrent writers. New shape: snapshot *VMRecord copies under the lock, then run ToVM outside.
  • utils.ScanProcsByBinary cache (Q+E support bridge tap to reduce hop between tap & nic #19): FindVMMByCmdline walks all of /proc per call; DeleteAll invokes it once per VM, so batch vm rm of N VMs scans /proc N times. New ProcScan walks once, callers call Find(sockPath) per id to filter the cached cmdlines. FindVMMByCmdline is preserved as a one-shot wrapper for single-VM callers (WithRunningVM). Non-linux stubs added.

Skipped from the audit:

Based on refactor/dedup-helpers (PR #59) to avoid hypervisor/inspect.go conflict.

Test plan

  • make fmt-check && make lint && go test -race ./... — 21 packages green, lint 0, fmt 0
  • GOOS=linux go build ./... — non-linux stubs verified
  • AST layout audit — 0 violations

@CMGS CMGS force-pushed the perf/batch-tx-and-cache branch 7 times, most recently from c9ac559 to 85a0da8 Compare May 20, 2026 09:48
- 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.
@CMGS CMGS force-pushed the perf/batch-tx-and-cache branch from 85a0da8 to 109765e Compare May 20, 2026 09:58
@CMGS CMGS merged commit 58741ad into master May 20, 2026
4 checks passed
@CMGS CMGS deleted the perf/batch-tx-and-cache branch May 20, 2026 10:02
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.

1 participant