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

Reduced render time for bars by 60-80%, by caching IsSpatial #5026

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

degracode
Copy link
Contributor

In my profiling, GetSpatialColor represents 33% of the time spent inside BarsEffect::Render, just checking buffer.palette.IsSpatial(colorIdx) for every pixel. If you're not using spatial colors, this time is pure wastage. The optimiser can't see deep enough to know that it can cache IsSpatial, so I've done it manually. Despite expecting a saving of only 33%, it's actually more like 60%, because skipping the GetSpatialColor function call also skips all of the maths done to build its parameters, such as (float)x / (float)buffer.BufferWi, and (float)(n % barHt) / (float)barHt.

5.878s -> 2.184s for my test sequence, that is one bars effect with 3 colours, across all channels.

More savings could undoubtedly be had by performing this same optimisation on other effects.

In my profiling, GetSpatialColor represents 33% of the time spent inside BarsEffect::Render, just checking buffer.palette.IsSpatial(colorIdx) for every pixel. If you're not using spatial colors, this time is pure wastage.
The optimiser can't see deep enough to know that it can cache IsSpatial, so I've done it manually. Despite expecting a saving of only 33%, it's actually more like 60%, because skipping the GetSpatialColor function call also skips all of the maths done to build its parameters, such as `(float)x / (float)buffer.BufferWi`, and `(float)(n % barHt) / (float)barHt`.

5.878s -> 2.184s for my test sequence, that is one bars effect with 3 colours, across all channels.

More savings could undoubtedly be had by performing this same optimisation on other effects.
@degracode
Copy link
Contributor Author

Build failure is unrelated to PR; looks like 602444a is the cause.

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.

1 participant