Repository navigation
Journal: cap by serialized size and keep a recording's start through trims - #1230
Open
marcoarnulfo wants to merge 1 commit into
Open
marcoarnulfo wants to merge 1 commit into
marcoarnulfo wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Part of #1228.
Thanks @ds-8362 for the measurements, they made this easy to pin down.
Session::executecapped the journal only by entry count (10,000, trimmed to 5,000), so a fewfile.openentries with their base64 could hold tens of MB. This adds a byte cap: each entry's serialized size is measured once when it's pushed and kept alongside, and past 64 MB the oldest entries go until the journal is under half, the same way the count cap works. The newest entry always stays, even if it's bigger than the cap on its own. 64 MB is my guess at a sensible value, happy to switch to whatever you prefer.While in there I found that trimming left
Session::recordingpointing at the old index, so a recording that spanned a trim saved a script with zero steps. The index now shifts with the trim (saturating at 0). Steps the trim dropped are still lost.I left
journal_paramsalone on purpose.automate.recordActionsturns journal entries into saved scripts, andengine.journalis documented as replayable, so swapping the base64 for a summary (name, size, hash) would stop a recordedfile.openorinsert.picturefrom replaying. If you'd rather have the summary and accept that trade-off, I can do it in a follow-up. Summarising largerange.setValuesarrays and paginatingengine.journalare also still open.Validation:
tests::journal_is_capped_by_serialized_size: fails on main (12 entries of 8 MB stay in the journal, over the cap), passes heretests::recording_keeps_its_steps_when_the_journal_is_trimmed: fails on main ({"recording":false,"saved":"Steps","steps":0}), passes herecargo test -p gridcraft-engine --libon the journal tests,cargo clippy -p gridcraft-engine --all-targets -- -D warnings,cargo fmt --all -- --check