Skip to content

ext4: add benchmarks mimicking creating a containerd rwlayer#366

Open
djs55 wants to merge 1 commit intodiskfs:masterfrom
djs55:ext4-create-benchmarks
Open

ext4: add benchmarks mimicking creating a containerd rwlayer#366
djs55 wants to merge 1 commit intodiskfs:masterfrom
djs55:ext4-create-benchmarks

Conversation

@djs55
Copy link
Copy Markdown
Contributor

@djs55 djs55 commented Apr 2, 2026

The first patch is #365 (to fix a journal issue). The second patch is new.

Thinking of nerdbox + containerd on Mac, where the writable layer is an ext4 filesystem created on the host: currently it uses mkfs.ext4, but it would be interesting if it could use go-diskfs instead.

This PR adds a benchmark, comparing it to mkfs.ext4:

go-diskfs % PATH="/opt/homebrew/opt/e2fsprogs/sbin:$PATH" \
        go test -bench BenchmarkCreate20GB -run '^$' -benchmem ./filesystem/ext4/
goos: darwin
goarch: arm64
pkg: github.com/diskfs/go-diskfs/filesystem/ext4
cpu: Apple M3 Max
BenchmarkCreate20GB-14                         2         515633521 ns/op        763341676 B/op   2789173 allocs/op
BenchmarkCreate20GBNoJournal-14                3         447836097 ns/op        762175229 B/op   2788775 allocs/op
BenchmarkCreate20GBMkfsExec-14               115          10447870 ns/op            9808 B/op         58 allocs/op
PASS
ok      github.com/diskfs/go-diskfs/filesystem/ext4     3.982s

(I added the unit test just to check the outputs are valid, separate from the benchmark itself)

So it's a bit slower (see the ns/op) but I've got some experimental patches which could speed it up. I'll make those as a separate draft PR and describe how I created them, in case you'd like to reproduce (since it was an AI investigation).

@deitch
Copy link
Copy Markdown
Collaborator

deitch commented Apr 3, 2026

Needs a rebase, and lint is failing

Add benchmarks for ext4.Create on 20 GB sparse images with metadata
checksums — the configuration used by containerd for writable container
layers. Includes a mkfs.ext4 reference benchmark for comparison.

Run all benchmarks (e2fsprogs must be on PATH for the mkfs.ext4 reference):

  PATH="/opt/homebrew/opt/e2fsprogs/sbin:$PATH" \
    go test -bench BenchmarkCreate20GB -run '^$' -benchmem ./filesystem/ext4/

Run e2fsck validation tests:

  PATH="/opt/homebrew/opt/e2fsprogs/sbin:$PATH" \
    go test -run TestCreateLazyInitE2fsck -v ./filesystem/ext4/

Results on Apple M3 Max (macOS, APFS):

  BenchmarkCreate20GB             484ms   763MB   2.79M allocs
  BenchmarkCreate20GBNoJournal    438ms   762MB   2.79M allocs
  BenchmarkCreate20GBMkfsExec      11ms    10KB      58 allocs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@djs55 djs55 force-pushed the ext4-create-benchmarks branch from 59d99fe to c3b17f9 Compare April 7, 2026 10:08
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.

2 participants