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

After logging system changes, calling SDL functions that error is far more expensive #9679

Open
Starbuck5 opened this issue May 3, 2024 · 0 comments
Assignees
Milestone

Comments

@Starbuck5
Copy link
Contributor

Hello,

We on the pygame-ce team recently put up a pre-release of our next version, and multiple people noticed poor performance in it.

We tracked the issue all the way down to a few errant uses of SDL_GetColorKey in our code without doing SDL_HasColorKey first, and this SDL commit a6d5c1f. (Between SDL 2.29.2 and 2.29.3). Our issue on this: pygame-community/pygame-ce#2821

I believe what's happening is that our function was using SDL_GetColorKey to check if a surface had color key, and inside SDL this was calling SDL_SetError, and that SDL_SetError internally had to call SDL_getenv every time, slowing the whole loop down tremendously versus SDL 2.28.5

(In our defense, the SDL_HasColorKey function was added after our code was originally written)

We'll work on making sure our functions aren't inducing SDL_SetError calls when they don't need to of course, but I opened this just to let the SDL maintainers know that calling functions that set errors is now much less performant in SDL 2.30.0.

I'm not sure there's really anything actionable here? For this dynamic logging feature with SDL_LOGGING, SDL_SetError has to check the environment every time? Caching it would be antithetical to the spirit of setting a logging env variable? Again, just opening this informationally in case there is anything actionable with it.

Thanks for maintaining this library!

@slouken slouken added this to the 3.2.0 milestone May 22, 2024
@slouken slouken assigned slouken and icculus and unassigned slouken May 22, 2024
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

No branches or pull requests

3 participants