Skip to content

perf(inode): compact lookupCount from 24-byte struct to 8-byte int64 - #5217

Draft
kislaykishore wants to merge 1 commit into
masterfrom
perf/lookup-count-memory-opt
Draft

kislaykishore wants to merge 1 commit into
masterfrom
perf/lookup-count-memory-opt

Conversation

@kislaykishore

@kislaykishore kislaykishore commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Optimize the in-memory footprint of lookupCount across all inode types (FileInode, dirInode, baseDirInode, and SymlinkInode):

  • Replace the 24-byte lookupCount struct (id fuseops.InodeID, count uint64, destroyed bool) with a compact 8-byte type lookupCount int64 (zero value initialized to 0, -1 sentinel for destroyed inodes, with overflow and underflow panics preserved).
  • Pass the inode's id to lc.Inc(id) and lc.Dec(id, n) instead of storing a duplicate fuseops.InodeID on every lookupCount.
  • Mark lookupCount as destroyed via lc.Destroy() (*lc = -1) in Destroy() across all inode types and remove the redundant FileInode.destroyed boolean field in favor of f.lc.IsDestroyed().
  • Saves 16 bytes per lookupCount across all inode types (and an additional 8-byte word on FileInode by eliminating FileInode.destroyed).

Link to the issue in case of a bug fix.

b/585048166

Testing details

  1. Manual - Verified compilation and static analysis via make build.
  2. Unit tests - Added unit tests in internal/fs/inode/lookup_count_test.go covering normal increment/decrement, reaching zero, panics after destruction, overflow/underflow panics, and idempotency of Destroy(). Verified go test -v -race ./internal/fs/inode/....
  3. Integration tests - N/A

Any backward incompatible change? If so, please explain.

N/A

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.13%. Comparing base (3ba00d9) to head (619b0b5).

Files with missing lines Patch % Lines
internal/fs/inode/base_dir.go 66.66% 1 Missing ⚠️
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              
Flag Coverage Δ
unittests 85.13% <96.15%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@kislaykishore
kislaykishore added this pull request to stack #5220 November 4, 2026 14:29
@kislaykishore
kislaykishore force-pushed the perf/lookup-count-memory-opt branch from 1d2768d to 3fcf840 Compare November 4, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant