Use a per-board save queue instead of a process-wide one - #391
Open
lovasoa wants to merge 1 commit into
Open
Conversation
Each board writes only its own files, so serializing saves process-wide made a slow rewrite on one board block unrelated boards. Move the SerialTaskQueue onto each BoardData instance so the concurrency lane is per board (and GC'd with the board).
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.
Use a per-board save queue instead of a process-wide one
saveBoardran every board's save through a single globalSerialTaskQueue, so a slow rewrite on one board blocked unrelated boards from persisting and delayed shutdown saves. Each board only ever writes its own files, so the lane only needs to be per board.The queue now lives on each
BoardDatainstance (data.mjs), so it is GC'd with the board (no globalMapto clean up).saveBoardnow usesboard.saveQueue. File writes stay safe because the queue still serializes each board's own writes, and no two boards share a file.Proof
The test blocks board A mid-save and shows board B completes anyway, then shows two saves of the same board stay serialized: