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

Refactor grouping to be much more efficient #31823

Merged
merged 5 commits into from
Feb 7, 2025

Conversation

peppy
Copy link
Member

@peppy peppy commented Feb 7, 2025

And probably easier code on the eyes too.

This sees a reduction of ~9 seconds to ~2 seconds with 200k beatmap sets.

The remaining largest bottleneck is string comparisons.

@bdach bdach self-requested a review February 7, 2025 08:16
@@ -36,7 +36,7 @@ public async Task<IEnumerable<CarouselItem>> Run(IEnumerable<CarouselItem> items
switch (criteria.Sort)
{
case SortMode.Artist:
comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(ab.BeatmapSet!.Metadata.Artist, bb.BeatmapSet!.Metadata.Artist);
comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(ab.Metadata.Artist, bb.Metadata.Artist);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno about these changes... Metadata is technically not supposed to vary within a single set, but it could, and I don't think we check that in any way. Could lead to some dumb shenanigans happening.

At least previously, because of going through the set, it was assured that every beatmap of a set had the same metadata (namely the metadata of the first beatmap in the set).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overhead of the set traversal was quite large (in the seconds for the performance test).

I don't see this change as an issue because if/when we change the correlation of metadata to sets/beatmaps, it's a given that we'd be examining every usage with a magnifying glass.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm understanding, the performance gain here is all from avoiding multiple iterations of items, correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The major gain was not using Insert on the list (~80%).

@bdach bdach merged commit a068d88 into ppy:master Feb 7, 2025
8 of 10 checks passed
@peppy peppy deleted the carousel-v2-optimisation-pass branch February 10, 2025 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants