-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Attempt to improve performance of beatmap carousel when not grouped by sets #35398
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
Conversation
Beatmap panels can be visible for very brief instants. `PanelSetBackground` has a backstop to prevent expensive background loads which is based on the position of the panel relative to centre of screen. However, retrieving the working beatmap that *precedes* any of that expensive background load logic, is *also* expensive, and *always* runs even if a panel is visible on screen for only a brief second. Therefore, by moving some of that background load delay towards delaying retrieving the working beatmap, we can save on doing even more work, which has beneficial implications for performance.
…nels The equality check that was supposed to replace the read of `CurrentSelectionItem` showed up as a hotspot in profiling. The selection updating code looks a little stupid after this, but all in the name of performance...
| var beatmapSet = beatmap.BeatmapSet!; | ||
|
|
||
| beatmapBackground.Beatmap = beatmaps.GetWorkingBeatmap(beatmap); | ||
| scheduledBackgroundRetrieval = Scheduler.AddDelayed(b => beatmapBackground.Beatmap = beatmaps.GetWorkingBeatmap(b), beatmap, 50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember testing this during original implementation but I couldn't see the overhead. I may have been incorrectly testing though, as working beatmaps do get cached after first load.
(And I guess that's one thing to note here – this is delayed the load even when they are cached already. Shouldn't change anything since you've just moved the delay from elsewhere, though.)
| { | ||
| var item = carouselItems[i]; | ||
|
|
||
| bool isKeyboardSelection = CheckModelEquality(item.Model, currentKeyboardSelection.Model!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit awkward but worth it for the huge performance boost.
RFC. Maybe addresses some of #34843.
Slightly delay retrieval of working beatmaps in song select panels
Beatmap panels can be visible for very brief instants.
PanelSetBackgroundhas a backstop to prevent expensive background loads which is based on the position of the panel relative to centre of screen.However, retrieving the working beatmap - which is done only for the purposes of displaying the backgrounds, and that precedes any of that expensive background load logic - is also expensive because realm detaches are expensive due to deep cloning via automapper, and always runs even if a panel is visible on screen for only a brief second. Therefore, by moving some of that background load delay towards delaying retrieving the working beatmap, we can save on doing even more work, which has beneficial implications for performance.
There's no great way to show profiling results for this, as the hopeful result is the decreased count of calls to
GetWorkingBeatmap(), which is a bit tricky to demonstrate when spamming F2 because how many retrievals happen depends on pure chance.This doesn't specifically impact standalone panels, which is why the commit also touches set panels, but is more noticeable on standalone panels because there are more panels with backgrounds in these cases.
Fix performance overhead when computing spacing between standalone panels
The equality check that was supposed to replace the read of
CurrentSelectionItem(see a3db764) showed up as a hotspot in profiling.The selection updating code looks a little stupid after this, but all in the name of performance...