Use fragment size for autoGC capacity calculation #3562
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our Darwin builders at work weren't running auto-GC despite being configured to, so I had to step in here and figure out what's going on.
Turns out that in
struct statvfs
,f_bsize
andf_frsize
are basically always the same on Linux, while on macOS,f_bsize
measures a completely different statistic (optimal I/O read size), see the man page here.On my relatively new MBP running Catalina on APFS,
f_bsize
is 1MB whilef_frsize
is 4KB (the actual block size). Since we usef_bsize
in the size calculation requirement, the capacity checks Nix does on Darwin are off by a factor of 256, and since we hadmax-free
configured, the machine was always considered to have ample space.The
gc-auto.sh
test can't catch this since it stubs the reported FS capacity, and also I don't think there's any reasonable way for us to catch this in a test.I don't think there should be anything wrong with using
f_frsize
for both platforms since the two fields seem to always be the same on Linux, see StackOverflow.