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

Ruleset.CreateIcon is inefficient in ruleset usages #11240

Open
peppy opened this issue Dec 21, 2020 · 7 comments
Open

Ruleset.CreateIcon is inefficient in ruleset usages #11240

peppy opened this issue Dec 21, 2020 · 7 comments
Labels
area:ruleset-api priority:2 Moderately important. Relied on by some users or impeding the usability of the game type:performance

Comments

@peppy
Copy link
Member

peppy commented Dec 21, 2020

It came to my attention that some rulesets are using sprites for their icons, creating a new TextureStore every call to CreateIcon(). This is super inefficient and may lead to memory exhaustion.

@peppy
Copy link
Member Author

peppy commented Feb 27, 2021

While looking into fixing this, we should also consider that calls to CreateIcon are dangerous, in that they may fail due to an API change (see #11912). There should probably be a path which can guarantee safety, at least at a constructor level. ie. rulesetStore.GetIconFor(ruleset), which provides a fallback icon if an exception is encountered).

@ayyEve
Copy link

ayyEve commented Feb 27, 2021

like a default ruleset icon if no specific-ruleset icon is found?

the order [api -> local ruleset icon -> default ruleset icon] would make sense imo
this would give top priority to the api (most up to date image), if none is found try to use a locally defined ruleset icon (in case a ruleset-author wants their own default fallback), otherwise use the default icon (so theres always something available)

@peppy
Copy link
Member Author

peppy commented Feb 27, 2021

I don't think you understand what you're saying here. This doesn't need open discussion; it's an issue (causing potential crashes) purely at the osu.Game end and the comment above was more for myself than anyone else.

@ayyEve
Copy link

ayyEve commented Feb 27, 2021

my mistake

@bdach
Copy link
Collaborator

bdach commented Feb 28, 2021

Some rulesets have more proper logic that performs a once-off registration of their resource store at game-level. It looks like a viable alternative, at least when it comes to the performance side of things, but I'm not sure if I like it 100%. It's a bit of a scary change to make since namespacing will begin to be a problem.

I also thought about having a separate texture store for just the icons in RulesetStore, but that's also a bit ugly. It'll mean that CreateIcon() will have to be able to accept it via a parameter, which seems like a worse API than what we have. The alternate proposed path via rulesetStore.GetIconFor(ruleset) would hide that a bit (along with maybe making CreateIcon() protected internal), but I'm not sure how I'd feel about sticking a texture store in RulesetStore.

@peppy
Copy link
Member Author

peppy commented Mar 2, 2021

That kind of "proper logic" is literally game breaking, and would not be allowed in a ruleset which is approved for ranking etc. (polluting a global texture store with one provided by a ruleset). This could be used to manipulate gameplay outside of the ruleset itself, after all.

I'd say that we do want to cache or maintain resource stores locally in RulesetStore if they are required for this purpose.

@bdach
Copy link
Collaborator

bdach commented Mar 2, 2021

Sure, I didn't intend to say it was completely correct, rather than it just being "more proper" from a performance standpoint. I understand the namespacing implications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:ruleset-api priority:2 Moderately important. Relied on by some users or impeding the usability of the game type:performance
Projects
None yet
Development

No branches or pull requests

3 participants