Skip to content

iostream: Create properties on-demand instead of upfront.#15980

Merged
slouken merged 1 commit into
libsdl-org:mainfrom
icculus:sdl3-iostream-props-on-demand
Jul 13, 2026
Merged

iostream: Create properties on-demand instead of upfront.#15980
slouken merged 1 commit into
libsdl-org:mainfrom
icculus:sdl3-iostream-props-on-demand

Conversation

@icculus

@icculus icculus commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator
  • I confirm that I am the author of this code and release it to the SDL project under the Zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

It's possible that IOStreams might get created and thrown away a lot, perhaps at any point in an app's lifetime, so it makes sense to avoid doing the work of maintaining a properties group for each, if the app hasn't requested it, since this requires a bunch of allocations and locks.

It's not necessarily worth doing this for other SDL objects, like SDL_Window, since there are likely to only be a few of them, and likely created at startup and living for the entire lifespan of the app.

Fixes #14436.

@icculus icculus added this to the 3.6.0 milestone Jul 12, 2026
@icculus icculus self-assigned this Jul 12, 2026
@slouken

slouken commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

It looks like this is crashing / failing automated tests, but conceptually seems fine. I don't think we need to go crazy with this in the general case though. Especially with the new hashtable implementation (that's still coming, right?), properties should be relatively inexpensive.

It's possible that IOStreams might get created and thrown away a lot, perhaps
at any point in an app's lifetime, so it makes sense to avoid doing the work
of maintaining a properties group for each, if the app hasn't requested it,
since this requires a bunch of allocations and locks.

It's not necessarily worth doing this for other SDL objects, like SDL_Window,
since there are likely to only be a few of them, and likely created at startup
and living for the entire lifespan of the app.

Fixes libsdl-org#14436.
@icculus
icculus force-pushed the sdl3-iostream-props-on-demand branch from f68a91f to 9b24398 Compare July 13, 2026 21:36
@icculus

icculus commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

I don't think we need to go crazy with this in the general case though.

Agreed. I kind of like the usage pattern of "a function pointer fires on creation to fill in current properties and never fires if we don't actually need it" but there's no way I'm going through and auditing the whole codebase to do this. :)

100% SDL_IOStream was the best candidate for this experiment and we'll call it done for now.

@icculus

icculus commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

Fixed the bug that the tests caught. This can merge whenever!

@slouken
slouken merged commit c9ebec4 into libsdl-org:main Jul 13, 2026
10 checks passed
@icculus
icculus deleted the sdl3-iostream-props-on-demand branch July 13, 2026 22:54
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.

Proliferation & performance of SDL_properties

2 participants