Improved graph.luau performance#77
Closed
Olaroll wants to merge 2 commits into
Closed
Conversation
Author
|
Oh I see, the |
Author
|
Found out there's a benchmark in the repo which ended up revealing some performance regressions in other areas. Sadly there doesn't seem to be any obvious way of fixing the regressions, so I'll have to take another look another day. I'll close the PR for now. If I find some breakthrough, I'll make a new one. |
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.
This PR should significantly increase Vide's performance, especially in cases where sources are being updated every frame.
In our game, I noticed that upon updating lots of camera distance sources every frame, there was a lot of performance being lost to Vide's source update internals, before it even got to my effect callbacks. Upon drilling down, I found the main culprit to be the
find_and_swap_pop()function, because it was doing removals withtable.find().I did a pass on the whole
graph.luaufile, keeping all behavior the same overall, but removing all cases oftable.find()and unoptimized loops. For our game, this made the aforementioned camera distance updates 4x faster.Here's the thoughts behind the changes:
{ Node }->{ [Node]: true }). This means iteration becomes unordered, but that should be fine becausefind_and_swap_pop()was changing the order arbitrarily anyway.table.find()being used onscopes, so I added an accompanyingactive_nodesset, which can be used to easily check if a node is present inscopes.I deletedDidn't see it was used for tests. Re-implemented asget_children()entirely because it isn't used anywhere in the codebase and I figured the main reason for its existence was that the children were stored as a mixed table. Now they can just be indexed directly vianode.children.get_children_as_array()to make it clear it's not free and a transformation is happening under the hood.