Repository navigation
perf: read the DIFAT, FAT and MiniFAT in whole sectors on open - #96
Merged
mdsteele merged 2 commits intoSep 20, 2026
Merged
Conversation
Opening loads the DIFAT, FAT, directory and MiniFAT. The existing disk benches include it, but mixed with the stream reads.
Opening a file read these tables one 4 byte entry at a time, and for the MiniFAT with a seek before every entry. On an unbuffered File that is one or two syscalls per entry: opening a 100 MB file took 42k reads and 15k seeks before any stream was touched. Read each DIFAT and FAT sector, and the whole MiniFAT chain, into a buffer and decode the entries from memory. The open_disk bench is 70 to 92% faster for the cases that have a FAT or MiniFAT of any size.
Contributor
Author
|
That was quick, thanks @mdsteele |
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.
Opening a file reads the DIFAT, FAT and MiniFAT one 4 byte entry at a time, and for the MiniFAT with a seek before every entry. On an unbuffered
Filethat is one or two syscalls per entry: opening a 100 MB file took 42k reads and 15k seeks before any stream was touched. This is most noticeable on network shares and when opening many files.Each DIFAT and FAT sector, and the whole MiniFAT chain, is now read into a buffer and the entries are decoded from memory. The same bytes are read as before, only in fewer calls. The extra memory is one sector buffer, plus a temporary copy of the MiniFAT while it is decoded.
The first commit adds an
open_diskbench group, since the existing disk benches mix the open with the stream reads. Results against that baseline:read_streams_diskimproves 17 to 86% as it includes the open. The rest of the bench suite is unchanged.