Repository navigation
perf(inode): compact lookupCount from 24-byte struct to 8-byte int64 - #5217
kislaykishore wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the lookupCount helper in internal/fs/inode from a struct to a custom int64 type, simplifying its initialization and reducing its memory footprint. The inode ID is now passed directly to the Inc and Dec methods instead of being stored within the struct, and a value of -1 is used to represent a destroyed state. This change also allows the removal of the redundant destroyed field in FileInode. Comprehensive unit tests have been added to verify the new implementation. No review comments were provided, and the changes appear to be clean and well-tested.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5217 +/- ##
==========================================
+ Coverage 85.12% 85.13% +0.01%
==========================================
Files 181 181
Lines 19848 19850 +2
==========================================
+ Hits 16895 16900 +5
+ Misses 2952 2949 -3
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1d2768d to
3fcf840
Compare
3fcf840 to
619b0b5
Compare
Description
Optimize the in-memory footprint of
lookupCountacross all inode types (FileInode,dirInode,baseDirInode, andSymlinkInode):lookupCountstruct (id fuseops.InodeID,count uint64,destroyed bool) with a compact 8-bytetype lookupCount int64(zero value initialized to0,-1sentinel for destroyed inodes, with overflow and underflow panics preserved).idtolc.Inc(id)andlc.Dec(id, n)instead of storing a duplicatefuseops.InodeIDon everylookupCount.lookupCountas destroyed vialc.Destroy()(*lc = -1) inDestroy()across all inode types and remove the redundantFileInode.destroyedboolean field in favor off.lc.IsDestroyed().lookupCountacross all inode types (and an additional 8-byte word onFileInodeby eliminatingFileInode.destroyed).Link to the issue in case of a bug fix.
b/585048166
Testing details
make build.internal/fs/inode/lookup_count_test.gocovering normal increment/decrement, reaching zero, panics after destruction, overflow/underflow panics, and idempotency ofDestroy(). Verifiedgo test -v -race ./internal/fs/inode/....Any backward incompatible change? If so, please explain.
N/A