Draft
Conversation
Draft
Cluedrew
reviewed
Mar 23, 2026
| :runner-spect-state (when runner-spectators? (strip-for-runner-spect replay-state corp-state runner-state)) | ||
| :hist-state replay-state}))) | ||
|
|
||
| (defn- fake-log-diff [old new] |
Contributor
There was a problem hiding this comment.
What makes this a "fake" diff? Is that it is too specialized, is it one sided?
Collaborator
Author
There was a problem hiding this comment.
I'm emulating what differ does, but skipping 99.9% of the work (in this extremely specialized case).
We have the following guarantees based on the structure of our product:
- both elements are vectors
- the
newelement will always either be the exact same as the older element, or be the older element with an additional tail
Which means that a lot of the work that differ does (in this specific case) is expensive and wasteful (indexing and equalizing 1-2k elements in the log for every single server frame).
The differ library we use is here: https://github.com/robinheghan/differ
Contributor
There was a problem hiding this comment.
But in that situation, does it actually diff its arguments?
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.
Turns out diffing two very long lists that are guaranteed to be identical except for the tail is probably overkill for our needs.
Cuts diff time for log messages from ~3-5ms to ~0.05ms for cases like chat.
Cuts diff time for log messages from ~3-5ms to ~1ms for cases like a game actions updating the log.
Both the above for cases where there's ~1k+ entries in the log (a normal game)
This needs to be stress tested on playtest before I'm confident in it entirely though.