Optimize playback: pt. 2#29
Merged
Merged
Conversation
- Use a cursor method to get keyframes according to the current frame position. This results in a dramatic 250x increase in playback performance! This allows SMH to handle even more entities (64 prop_physics with 1993 keyframes played ~30-60 FPS, or 256 prop_physics with 1993 keyframes at ~20 FPS) - Preserve the legacy method for setting frames, to allow features like smoothing to work - Also cache playback by player - Improve type annotations
Contributor
Author
|
Check this comment for a summary of the changes and my benchmarking |
- Previously, keyframe sorts happened per keyframe that gets moved. This would iterates over all keyframes to set previous/next references, which results in O(n^2) operations. This fixes that logic to only sort once after updating / copying keyframes
- Moving / copying keyframes sometimes crashes the game. I think it has to do with setting the previous and next keyframe references, so I'm clearing that to make sure that doesn't cause issues
vlazed
commented
Jul 9, 2026
vlazed
left a comment
Contributor
Author
There was a problem hiding this comment.
The result about 250x is incorrect. It should be a 1.1x increase for nonsmooth playback and a 13.68x increase for smooth playback. See this comment
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.
No description provided.