Skip to content

Conversation

@lidel
Copy link
Member

@lidel lidel commented Sep 18, 2025

adds auto-flush mechanism when directory cache exceeds 256 entries
(matching HAMT shard size). this prevents unbounded memory growth
when using --flush=false with many MFS operations.

the cache limit is currently hardcoded but marked as TODO for
future configurability.

related to ipfs/kubo#10842
adds SetMaxCacheSize methods to Root and Directory to allow
runtime configuration of the cache limit. subdirectories inherit
the parent's cache size setting.

this allows users to tune the cache size based on their needs:
- smaller for memory-constrained environments
- larger for heavy MFS usage
- 0 to disable limiting (old behavior)

related to ipfs/kubo#10842
@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 46.15385% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.64%. Comparing base (bd89313) to head (8a245fa).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mfs/dir.go 48.64% 14 Missing and 5 partials ⚠️
mfs/root.go 0.00% 2 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1037      +/-   ##
==========================================
- Coverage   60.65%   60.64%   -0.02%     
==========================================
  Files         268      268              
  Lines       33560    33599      +39     
==========================================
+ Hits        20357    20375      +18     
- Misses      11525    11540      +15     
- Partials     1678     1684       +6     
Files with missing lines Coverage Δ
mfs/root.go 30.00% <0.00%> (-0.69%) ⬇️
mfs/dir.go 51.55% <48.64%> (-0.29%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lidel lidel marked this pull request as ready for review September 18, 2025 13:52
@lidel lidel requested a review from a team as a code owner September 18, 2025 13:52
Copy link
Contributor

@gammazero gammazero left a comment

Choose a reason for hiding this comment

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

LGTM

@gammazero gammazero merged commit a04432d into main Sep 18, 2025
21 of 22 checks passed
@gammazero gammazero deleted the fix/mfs-cache-growth-issue-10842 branch September 18, 2025 22:08
lidel added a commit that referenced this pull request Sep 22, 2025
removes the cache auto-flush feature from #1037 that could cause
data corruption with parallel MFS operations.

letting applications implement their own safety mechanisms is safer
than enforcing automatic flushing in the library.

related to ipfs/kubo#10842
lidel added a commit that referenced this pull request Sep 25, 2025
removes the cache auto-flush feature from #1037 that could cause
data corruption with parallel MFS operations.

letting applications implement their own safety mechanisms is safer
than enforcing automatic flushing in the library.

related to ipfs/kubo#10842
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.

3 participants