Add support for on-disk SQLite store in computerd - #123
Open
aron-cf wants to merge 1 commit into
Open
Conversation
computerd keeps its workspace in memory, so a restart loses it and the durable object has to send every path again. On a large workspace that replay is most of the time it takes to get back to work. Set COMPUTERD_DB to an absolute path and the store goes on the container's disk instead. The sync positions live in the same database, so a restarted daemon still knows what it was sent and the durable object only sends the difference: about 25ms instead of a full resend, whatever the size of the tree. dofs gains a ./node export with NodeSQLiteStorage, which runs node:sqlite against a file or memory. It stays out of the main entry point because that has to load under workerd, which has no node:sqlite. SQLiteTestStorage is now the in-memory pinning of the same class. Also adds POST /__computerd/checkpoint for folding the write-ahead log back before a disk snapshot, reports the store on /__computerd/info, and adds store size and free pages to /__computerd/stats. Measured with script/store-compare.mjs and script/restore-time.mjs; numbers in packages/computerd/bench-results.md. Reads are not slower on disk. Writes cost 10 to 20 percent more through a real FUSE mount. The in-memory store stays the default.
🦋 Changeset detectedLatest commit: aa4f984 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
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.
computerdkeeps the workspace in memory. When it restarts, the store is gone and the durable object sends every path again before any command can run. For unsynced directories like node_modules this requires a full re-build.Set
COMPUTERD_DBto an absolute path to use a SQLite DB on disk, this can then be backed up and restored across container instances.The path must be absolute and must sit outside
MOUNT_POINT. A database the mount also shows would feed its writes back to itself.computerdrefuses to start on either mistake.The cloudflared process then starts back knowing what it was already sent, so only the difference needs to be synced.
POST /__computerd/checkpointcollapses the write-ahead log back into the database file, so a snapshot holds one file instead of two. The same happens onSIGTERM, after the mount is released — the mount writes buffered bytes as it closes each file, so it has to go first.GET /__computerd/inforeports the store in use, andGET /__computerd/statsreports its size.Restart by hand
Tests cover the storage layer, the new setting, and the point of the change: restart on a file store and the files and sync positions are still there, restart in memory and they are not. The unmount-then-checkpoint order has its own test, since reversing it would lose the last writes quietly. The
computerdREADME covers the setting and its limits, and the performance document carries the numbers.