-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
local-file-storage: scalability + race fixes
This commit fixes race conditions and potential performance issues ## Race conditions: - Multiple calls to `set` caused race conditions with the central metafile index. - Not only did this cause the set to fail, but it often corrupted the metafile causing a permanent, unrecoverable error since the metafile could no longer be parsed. ## Scalability: - The single metadata file would eventually grow large in a successful application and become both a memory issue and performance bottleneck - Additionally, storing all files in a single directory would eventually slow down the file system’s access of files in the directory. ## Changes: - Removes race conditions with atomic reads/writes - Removes the metafile and instead relies on SHA-256 hashes for file keys - Stores metadata alongside each file as .meta.json instead of central index - removes filename collision handling since it’s unnecessary with hash-based names - Performance - Shards files into subdirectories using first 8 chars of SHA-256 hash to maintain file system performance - Without a metafile, it is no longer a memory or performance bottleneck Should rebase/squash the commits before merging, added the failing test first to prove the bug.
- Loading branch information
1 parent
f8ba37a
commit a5b04fd
Showing
2 changed files
with
54 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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