Skip to content

Optimize playback: pt. 2#29

Merged
vlazed merged 4 commits into
PEAK-Incompetence:mainfrom
vlazed:playback-optimization-2
Jul 6, 2026
Merged

Optimize playback: pt. 2#29
vlazed merged 4 commits into
PEAK-Incompetence:mainfrom
vlazed:playback-optimization-2

Conversation

@vlazed

@vlazed vlazed commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

vlazed added 2 commits July 5, 2026 19:53
- 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
@vlazed vlazed mentioned this pull request Jul 6, 2026
@vlazed

vlazed commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Check this comment for a summary of the changes and my benchmarking

@vlazed vlazed changed the title Playback optimization: pt. 2 Optimize playback: pt. 2 Jul 6, 2026
vlazed added 2 commits July 6, 2026 18:29
- 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 vlazed merged commit 3a454d5 into PEAK-Incompetence:main Jul 6, 2026

@vlazed vlazed left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant