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

[c] spAnimationState_apply optimization #1117

Closed
ievgenmukhin opened this issue May 24, 2018 · 5 comments
Closed

[c] spAnimationState_apply optimization #1117

ievgenmukhin opened this issue May 24, 2018 · 5 comments
Assignees

Comments

@ievgenmukhin
Copy link
Contributor

spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name) {

spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name) which is called for each timeline in spAnimationState_apply consumes most of CPU time during animation state applying, especially for spine files with large amount of images. We have spine file with ~1000 images for pre-rendered animations, some of them used in more than one bone, resulting in ~8K entries in _spSkin. With such file we have very low framerate on older hardware.

Adding hashtable to _spSkin for fast Entry lookup gives us ~40x performance gain on such large spine animations.

@badlogic
Copy link
Collaborator

Ay, spSkin_getAttachment performs a linear search through the slot/name entries. Replacing that with a map definitely gives a good speed up. If you have made this change already, we are happy to merge a pull request. Otherwise I'll look into fixing it up asap.

@badlogic badlogic self-assigned this May 27, 2018
@ievgenmukhin
Copy link
Contributor Author

Hi, I have implemented this as temporary fix using 3rd party code from public domain for string hashing (murmur hash), so I'm not sure if it can be merged to your code base. I can update my fix with string hashing which is good for you, and create pull request if you want.

@badlogic
Copy link
Collaborator

Murmur should be fine license wise. Happy to merge your PR!

ievgenmukhin added a commit to ievgenmukhin/spine-runtimes that referenced this issue May 28, 2018
@ievgenmukhin
Copy link
Contributor Author

Did you have a chance to check my PR? #1118

@badlogic
Copy link
Collaborator

badlogic commented Jun 5, 2018

I've commented on your PR! Sorry for the delay. Let's continue tracking this in the PR, closing this out.

@badlogic badlogic closed this as completed Jun 5, 2018
ievgenmukhin added a commit to ievgenmukhin/spine-runtimes that referenced this issue Jun 5, 2018
badlogic pushed a commit that referenced this issue Jun 7, 2018
* [c] Optimized attachment lookup in skin. See #1117.

* [c] Optimized attachment lookup in skin. See #1117. Changes according to suggestions in PR #1118.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants