Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render loop optimisations #2722

Merged
merged 2 commits into from
Jul 9, 2024
Merged

Render loop optimisations #2722

merged 2 commits into from
Jul 9, 2024

Conversation

mattgperry
Copy link
Collaborator

@mattgperry mattgperry commented Jul 9, 2024

Closes #2720

This takes a similar but slightly different approach to the linked PR.

The frameloop was originally a very small standalone library (and could be again?) so there's a focus on filesize where performance isn't really affected.

As the .reduce was the smallest implementation and is only called twice, this was chosen here.

The linked PR introduces a hoisted runNextFrame which is a good idea, probably the source of the "hot" function so makes sense to define it just once.

Here I've taken the linked PR's idea of unrolling the render steps but, instead of doing it in performance-insensitive areas where there's that trade of bundlesize, doing in the render loop itself which runs every frame and is highly performance sensitive.

Finally I've taken the linked PR's approach of replacing the forEach in the cancel function with a for loop, removing a function assignment. It should be that cancel is performed quite infrequently but it's also true that you never know.

@kurtextrem
Copy link
Contributor

looks good to me

@mattgperry mattgperry merged commit 20a64f5 into main Jul 9, 2024
1 check passed
@mattgperry mattgperry deleted the perf/render-loop branch July 9, 2024 10:34
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.

2 participants