Repository navigation
Free space is asked of Finder once per disk every 3 s, not per destination every 500 ms (refs #478) - #497
Merged
Conversation
…ation every 500 ms (refs #478)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Open questions: None
What changed
The engine looks at every destination every 500 ms, and each look called Foundation's free-space query (
space::finder). That query walks every volume through IOKit: about 9 ms of CPU a call (95 ms the first time in a process), mostly sys.space::Cachenow keeps Finder's figures per disk (keyed bystatfs's fsid and mount) for 3 s, so destinations on one disk share an entry.statfsis still read at every look.Cache::refresh()forgets everything, and it is called when:Free-space refusals before a move (
moving::room) usestatvfsdirectly and are unaffected. Stall detection is unaffected: a stalled query is a cache miss, and nothing holds the lock while it runs.What users notice
The free-space figure can lag a write by up to 3 s. It refreshes at once on a full disk, on a drive going or coming back, and on Check. Deletes show at once (the fresh
statfsfigure is higher than the cached Finder one, so it wins).CPU
cargo nextest run -p service -E 'binary(phantom-service)' --no-fail-fast, timed with/usr/bin/time -p(it includes nextest and its children). "Before" is the same code with the cache time set to 0.CPU fell by 28% (sys by 40%). Wall time isn't comparable: the machine's load was 30–55 throughout. The 4 tests that failed in the "after" run (all load timeouts) pass when rerun alone.
Tests
a_disk_is_asked_once_in_3_s_and_again_after: same disk within 3 s isn't re-queried, after expiry it is, another disk has its own entry.a_refresh_makes_the_next_look_ask_again: refresh forces a new query, and an answer in flight across a refresh isn't kept.the_free_space_shown_follows_writes_and_deletes_on_the_disknow refreshes after each write, with no sleeps.cargo nextest run --workspace: 1303 passed;cargo test -p gui --test appkit: 5 passed;cargo fmt --checkclean, no warnings.Refs #478