Repository navigation
perf(rendering): skip re-sorting mask keyframes that are already in order - #2767
Open
celeroncoder wants to merge 1 commit into
Open
celeroncoder wants to merge 1 commit into
celeroncoder wants to merge 1 commit into
Conversation
Contributor
|
@celeroncoder is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
cc @richiemcilroy, this is the mask-keyframe half you suggested filing on its own; the timeline hold-window part is dropped. |
Contributor
|
@celeroncoder is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
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.
interpolate_vectorandinterpolate_scalarincrates/rendering/src/mask.rscopied and sorted the keyframe list on every call. They run once per frame for each active mask's position, size and intensity tracks (frominterpolate_masks, twice per frame during a transition), and the keyframes are static for the life of the project, so the copy and the sort were repeated for nothing.Change
One private helper,
sorted_by_time, returns the keyframes as a borrowed slice when every adjacent pair is already in non-decreasing time order, and only clones and sorts otherwise. Both interpolation functions use it; their bodies are otherwise unchanged.sample_trackincamera3d.rsfrom perf(rendering): avoid cloning sorted 3D camera tracks #2503.<=false, so that input still takes the old clone-and-sort path.partition_point), so the fast path is the normal case;cap project config setcan write arbitrary JSON, which is why the check stays at runtime rather than sorting at load. Sorting at load was rejected becauseProjectConfiguration::writeround-trips the arrays as-is.Tests compare both functions against a verbatim copy of the old code for sorted, unsorted, tied, empty and single-key input at boundary, NaN and infinite query times, and pin that ordered input is borrowed and unsorted or NaN input is sorted.
Results
Standalone copies of the old and new
interpolate_vector, release build, 100k calls, 2 vCPU aarch64 Linux box: 8 already-sorted keys 35.0 ns → 14.7 ns per call; 8 unsorted keys 68.6 ns → 70.3 ns (the cost of the check). This is an allocation cleanup on a per-frame path, not a visible frame-time change.Overlap
interpolate_masks; this PR removes the per-call keyframe copy inside the interpolation of the masks that survive that filter. The two edit different parts ofmask.rsand apply cleanly in either order. perf(rendering): filter inactive masks before sorting #2578's benchmark uses empty keyframe tracks, so its numbers don't cover this path.How this was made
This PR is agent-generated.
mainby OpenCode scouts and Gemini 3.8 Flash; the maintainer asked for this part to be filed on its own.main.#[inline], a NaN-only differential case) were folded in.🤖 Generated with Claude Code