Optimize animation performance and improve internals#112308
Conversation
a5d9659 to
ba1f999
Compare
| thread_local AnimationNode::ProcessState *AnimationNode::tls_process_state = nullptr; | ||
| thread_local AnimationNodeInstance *AnimationNode::current_instance = nullptr; |
There was a problem hiding this comment.
I think the difference from #110474 is that this was added. Are there any other changes? Is a new benchmark comparison possible?
If #110474 (review) issue was due to multiple same AnimationNode resources being instantiated and placed, then the fix to manage each resource's instance makes sense. I confirmed that this no longer causes #110474 (review) issue.
However, since I recall past issues similar to #110506, I'm a bit concerned about whether using thread_local is appropriate. Testing in a project editing scenes containing a large number of AnimationTree instances might be necessary.
Also, I have some concerns regarding code readability. Passing instance pointers as arguments is indeed safe, but since there should be never occur to access different ProcessState and AnimationNodeInstance within a single AnimationNode like:
double length_a = instance_a.get_parameter(current_length);
double length_b = instance_b.get_parameter(current_length);
, so it always p_instance.get_parameter(), it would be ideal if there is a way to omit them, same with old code. This would significantly reduce the number of lines requiring modification. Do you have any ideas @lyuma @SaracenOne?
If there are no other way, I assume it can be accepted depending on the benchmark improvement. In other words, we want a benchmark comparison before and after, focusing solely on changes to the AnimationTree instance, excluding any other changes. This was one reason why I suggested separating the PR.
There was a problem hiding this comment.
We briefly discussed this at the animation meeting and agreed that passing references as arguments is acceptable.
We still have some concerns about thread_local, so we will continue reviewing it. cc @lyuma
dee1843 to
557e35d
Compare
|
I'll upload performance benchmarks soon, but for review, is it better if I squash the commits? Or leave it as it is? Also regarding this
It actually is present in BlendSpace1D and 2D https://github.com/godotengine/godot/blob/dee1843b12d9950f21bed4c3986e14090388e490/scene/animation/animation_blend_space_1d.cpp#L386 https://github.com/godotengine/godot/blob/dee1843b12d9950f21bed4c3986e14090388e490/scene/animation/animation_blend_space_2d.cpp#L552 |
2828a35 to
959c717
Compare
959c717 to
b3e2a2a
Compare
b3e2a2a to
8e916a9
Compare
I agree, but splitting it now would be very painful. It's already squashed into a single commit, I don’t have a good workflow to split it apart, and many of the changes are interdependent (so I’m not sure how to structure the PRs correctly). Although it’s not ideal, I’d prefer to just get this PR through the door as-is. If a major issue comes up afterward, I’ll take a look and consider splitting it then. |
|
If dependencies exist, you can create a PR using that as the branch base (like #112302 tree). For example, you could create one commit for the HashMap change and then create three PRs branching from it. It also helps visualize where dependencies occur so that we can prioritize and carefully review the ancestor of the dependencies. If they truly must be merged simultaneously, it would mean class dependencies are broken (e.g. the case that AnimationTree causes strong dependencies on AnimationPlayer). However, this PR doesn't appear to be that case, so it should be splittable. |
|
@Ryan-000 For now, I've split it into the following 5 parts as examples, please verify if they are correct.
If you need to manage them on your master, I will close those PRs and supersede them with yours, so please mention me after opening the PR. |
|
Thanks a lot for taking the time to split these PRs out for me, the structure looks good. One question though, there seems to be a merge conflict in |
|
If you prefer, I can resolve the conflicts on my PR. However, if you wish to manage them yourself (such as when you want to make changes based on the points raised), please create a new pull request (you can check out my branch, and My guess is that whether we accept #113448 or not will change the branch base, so I believe we should focus first on measuring #113448 benchmarks. |
|
@Ryan-000 @TokageItLab What is the state of these improvements ? Is there anything I can try in my Godot 4.6 based game? Animation performance is currently a bottleneck and maybe I can use some of this work instead of modifying the engine myself? |
|
Since the addition of high-priority features for 4.6 has been completed, I think that 4.7 will primarily focus on optimization work aimed at improving performance. We are currently busy with fixing bugs that occurred in 4.6, but I will start working on these optimizations as soon as that is finished. |
That sounds great. I am open to taking some risks with an early version of the optimizations that I build myself if they were mergable 😅 |
|
@TokageItLab If needed I can rebase and reopen #113442 and #113444, I just need to know once the maintainers have time to review them, so I’m not rebasing unnecessarily. |
|
@Ryan-000 Sounds good. I'd really like to see that merged into 4.7, so it would be a huge help if you'd do that :) Then, I will close them after you send that PRs. |
|
Is this superseded by #117277 ? |
Supersedes #110474
See #112308 (comment) for benchmarks
Bugsquad edited:
Captureblend mode inBlendSpace1DandBlendSpace2D#112053