-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partitioned file storage #35
Merged
Merged
Conversation
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
cute-the-niini
added
enhancement
New feature or request
c:kernel
Changes to the Kate emulator kernel (requires strict audits!)
labels
Dec 25, 2023
cute-the-niini
added a commit
that referenced
this pull request
Dec 25, 2023
The idea is that this will replace all current uses of IndexedDB as a file storage, consequently reducing the amount of blobs the browser needs to move around when iterating over the tables (and also reduce some of the awkward normalisation needs currently employed). This does have the nice effect of making the interference between different cartridges' data a bit less of a pain. This patch in particular only introduces the partitioned file storage and changes the cartridge data storage to use it. The file storage is based around reference-counted buckets that hold arbitrary numbers of objects, similar to what you would get with cloud object storages (other than the reference-counted part). Being reference-counted, there's a separate GC process that will now reclaim storage space whenever a bucket's reference counter reaches 0. This works similarly for temporary buckets and persistent ones --- a persistent bucket just has references held by a long-lived entity, such as a row in the database, instead of a JS memory reference. For tracking JS references it holds a set of weak references and finalisers to clean up the set. Cartridge installation is no longer fully-transactional as a result of this, because OPFS is not transactional. Instead, the process first creates a new bucket that holds all of the files in the cartridge, persists it, then attempts to create a database entry for the cartridge metadata (pointing to the persisted bucket). If it fails, the GC will validate that the persistent reference is still in effect next time it runs, and will decrease the counter accordingly if the row that's supposed to point back to the bucket is not in the database, consequently allowing the bucket's resources to be freed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
c:kernel
Changes to the Kate emulator kernel (requires strict audits!)
enhancement
New feature or request
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.
The idea is that this will replace all current uses of IndexedDB as a file storage, consequently reducing the amount of blobs the browser needs to move around when iterating over the tables (and also reduce some of the awkward normalisation needs currently employed). This does have the nice effect of making the interference between different cartridges' data a bit less of a pain.
This patch in particular only introduces the partitioned file storage and changes the cartridge data storage to use it. The file storage is based around reference-counted buckets that hold arbitrary numbers of objects, similar to what you would get with cloud object storages (other than the reference-counted part). Being reference-counted, there's a separate GC process that will now reclaim storage space whenever a bucket's reference counter reaches 0. This works similarly for temporary buckets and persistent ones --- a persistent bucket just has references held by a long-lived entity, such as a row in the database, instead of a JS memory reference. For tracking JS references it holds a set of weak references and finalisers to clean up the set.
Cartridge installation is no longer fully-transactional as a result of this, because OPFS is not transactional. Instead, the process first creates a new bucket that holds all of the files in the cartridge, persists it, then attempts to create a database entry for the cartridge metadata (pointing to the persisted bucket). If it fails, the GC will validate that the persistent reference is still in effect next time it runs, and will decrease the counter accordingly if the row that's supposed to point back to the bucket is not in the database, consequently allowing the bucket's resources to be freed.