Skip to content

perf: zero only what a read could see, not every new block - #185

Open
mattmattox wants to merge 2 commits into
mainfrom
perf/narrow-zeroing-3
Open

mattmattox wants to merge 2 commits into
mainfrom
perf/narrow-zeroing-3

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Re-lands #160, which #162 reverted, with the fix for what made it corrupt data.

Cause: zeroRange wrote buf.Bytes(). GetBuffer rounds sizes up to 4 KB, 64 KB, 256 KB or 1 MB, so a tail zero ending at a block boundary also zeroed up to 768 KB of the next physical block, which another file or directory owned. All three soak failures on daa33a6 trace to one such write:

  • failure 2: phys 61, a file's data;
  • failure 3: phys 140, a directory's entries;
  • failure 4: phys 80, a directory's entries.

TestZeroRangeZeroesOnlyItsRange fails on 4 of its 6 ranges without the fix.

Evidence:

  • daa33a6 failed 3 times within 1,520 ops. daa33a6 with only the one-line fix ran 9,655 ops clean.
  • This branch, before rebasing onto main, ran a 6.5h soak with faults and hourly fsck: it passed with 136,067 ops, 39 faults (16 power, 8 sigkill, 15 stop) and 6 clean fscks with no leaks.
  • After the rebase: the zeroing, power-cut and symlink tests pass, and so does -race on goclusterfs (996 s).

Audit: every place that reads or writes a pooled or aligned buffer. Only zeroRange wrote more than it meant to.

Site Size asked I/O Verdict
goclusterfs zeroRange to-from, any sector multiple write Bytes() wrote past to; fixed
goclusterfs write RMW, read loop, freeSFBSlot 4 KB read/write exact pool size
goclusterfs readSFB variable read [:length] sliced
goclusterfs migrateToExtent 1 MB write [:BlockSize] sliced
goclusterfs symlink target (#172) 1 MB write, 4 KB read Bytes() exact
extent CopyBlockData 1 MB read/write Bytes() exact
extent tree ReadTreeNode, writeNode variable [:size] sliced
dir block and chunk I/O 1 MB, 4 KB [:BlockSize], [:DirChunkSize] sliced
inode sector I/O 4 KB Bytes() exact
inode scanMagic 1 MB read [:sectors*SectorSize] sliced
journal append, ReadAt variable [:alignedLen] sliced
journal superblock 512 B / 4 KB read/write Bytes() one 4 KB sector
bitmap, refcount, snapshot sector I/O 4 KB Bytes() exact
lock slots and rows, node registry, superblock 4 KB, 256 KB Bytes() or sliced exact
fsck NewAlignedBuffer callers, including the new symlink and snapshot sector checks sector multiples, no pool Bytes() exact

🤖 Generated with Claude Code

mattmattox and others added 2 commits November 16, 2026 19:58
Re-lands #160, which #162 reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… buffer

The pool rounds sizes up, so zeroing a block's tail also zeroed up to 768 KB of
the next block, which another file or directory owns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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