Skip to content

imagecache: replace mountinfo scan with statx - #3835

Draft
Diamond (diamondburned) wants to merge 1 commit into
agent-substrate:mainfrom
diamondburned:feat/imagecache-statx-unmount
Draft

Diamond (diamondburned) wants to merge 1 commit into
agent-substrate:mainfrom
diamondburned:feat/imagecache-statx-unmount

Conversation

@diamondburned

Copy link
Copy Markdown

Summary

UnmountAllUnder parsed /proc/self/mountinfo on every actor restore and teardown, scanning all cached overlay layer mounts on the node under the kernel mount-namespace lock.

  • Walks the target directory with dirfd-relative statx and STATX_ATTR_MOUNT_ROOT across bounded passes instead, skipping overlay upper/work scratch trees and unmounted bundle rootfs/volume directories.
  • Fails loudly if STATX_ATTR_MOUNT_ROOT is unsupported on the backing filesystem, and detaches broken or disconnected mounts that fail statx/open/readdir with ENOTCONN, ESTALE, or EIO.
  • Deletes the now-unused mountinfo parser and its unit test, and adds BenchmarkUnmountAllUnder comparing bundle unmount under ambient mount-table noise.

Benchmark (benchstat)

Reproducible on Cloudtop via unshare -Urm go test -run='^$' -bench='^BenchmarkUnmountAllUnder$' -benchmem -count=10 ./internal/imagecache:

goos: linux
goarch: amd64
pkg: go.ate.dev/substrate/internal/imagecache
cpu: AMD EPYC 7B13
                   │  before.txt  │              after.txt               │
                   │    sec/op    │    sec/op     vs base                │
UnmountAllUnder-64   228.5µ ± 3%   168.0µ ± 2%  -26.45% (p=0.000 n=10)

                   │  before.txt  │              after.txt               │
                   │     B/op     │     B/op      vs base                │
UnmountAllUnder-64   4.125Ki ± 0%   2.318Ki ± 0%  -43.80% (p=0.000 n=10)

                   │ before.txt │               after.txt               │
                   │ allocs/op  │  allocs/op   vs base                  │
UnmountAllUnder-64   4.000 ± 0%   64.000 ± 0%  +1500.00% (p=0.000 n=10)

Verification

  • go test -race -count=3 -shuffle=on ./internal/imagecache/...
  • unshare -Urm go test -count=1 -v -run Unmount ./internal/imagecache/...
  • ./hack/verify/boilerplate.sh && ./hack/verify/gofmt.sh && ./hack/verify/package-deps.sh

🤖 PR was made with the use of generative AI.

UnmountAllUnder parsed /proc/self/mountinfo on every actor restore and
teardown, scanning all cached overlay layer mounts on the node under the
kernel mount-namespace lock.

Walk the target directory with dirfd-relative statx and
STATX_ATTR_MOUNT_ROOT across bounded passes instead, skipping overlay
upper and work scratch trees and unmounted bundle rootfs and volume
directories, failing loudly if STATX_ATTR_MOUNT_ROOT is unsupported, and
detaching broken or disconnected mounts that fail statx with ENOTCONN,
ESTALE, or EIO. Delete the now-unused mountinfo parser and its unit
test.

This branch has not been deployed

No deployments
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