-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Speed up Star Ratings recalculation and User Tags population processes
#36128
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
base: master
Are you sure you want to change the base?
Speed up Star Ratings recalculation and User Tags population processes
#36128
Conversation
|
Did you try performing any operations when testing this? It should deadlock. Realm doesn't support multiple concurrent writes, so holding writes open for long periods as you are doing here, would under my presumptions, cause something like running gameplay (and triggering an update-thread-bound write) to freeze the game. |
|
when it was recalculating beatmaps i was scrolling though song select and it was working fine, let me test it gameplay and song select once again. If it wont work i'll try another approach i have in mind |
|
Please air the other solution before you work on it, because if it's what I think you're planning it likely has other implications. |
|
Doing intermittent writes like that will delay the updates from being visible. It also increases the size of individual transactions. Maybe okay, but will need due consideration. And it likely will not fix the "abysmal performance" group of users, who actually see things taking seconds per realm write. What we really need there is to find someone who gets very low performances on realm transactions and figure out what is causing that, rather than working around the issue. |
|
hmm, best candidates for testing that people who have their lazer files/ and realm.client on HDD. So using bulk update by 100 beatmaps in |
|
Does it add overhead while updating? If so, that's my concern. Put another way: we want to be able to run background operations like this without the user being concerned they are running. Making it run faster is fine and all, but it's not fixing the actual issue we are dealing with. So this is super low priority as long as all that's happening is "batching more". |
|
idk how to measure overhead, but here's video with performance graph with calculating star ratings and scrolling in song select. Closer to the end i rerun calculations with small chunk of maps and then started updating tags (both used bulk, star ratings 100, user tags 500): https://youtu.be/m_7wohmkI5U with only user tags updating: https://youtu.be/6X7xrV1VsyA recalculating 5k maps: user tags (doesnt lag in song select for me): |
Star Ratings recalculation and User Tags population processesStar Ratings recalculation and User Tags population processes

a month ago i noticed that populating user tags takes a very long time and i got curious if it because of web requests or not, and only today i was able to check it out. Turns out it was writing to realm of each loop iteration which very very slow process considering that some people have more than 10_000 beatmaps.
As a solution, I moved
realmAccess.WriteandrealmAccess.Runoutside of the loop to speed up process. I dont know much about realm and not entirely sure if it's good solutionStar Ratings recalculation (2.3x speed up)
For benchmarking i waited until 5k beatmaps were recalculated, and speed up on my machine was by
Populating User Tags (69.3x speed up)
I waited for all 25709 user tags to be populated
Tests done offline on 7000mb/s read and 5000mb/s write SSD
Notes and questions
i applied the same changes to
processBeatmapsWithMissingObjectCounts,processScoresWithMissingStatistics,convertLegacyTotalScoreToStandardised,upgradeScoreRanksandbackpopulateMissingSubmissionAndRankDates, but didnt benchmark them.I didnt touch
processOnlineBeatmapSetsWithNoUpdatebecause it making web requests to server(?) and im not sure if i should touch this function.I have a question about
processBeatmapsWithMissingObjectCounts: this function callsbeatmapUpdater.ProcessObjectCountsto update beatmap object count, but this function hasbeatmapInfo.Realm!.Writein it which will slow recalculation process, in that case can this function be moved toprocessBeatmapsWithMissingObjectCountsfunction instead? since it's the only place it's used in.Also i'm not so sure about
backpopulateMissingSubmissionAndRankDatesis it only reads data from local storage without making requests to server?Another question i have: how realm.write works, does it finishes after file is fully saved and then
completeNotificationcalled?A concern i have with this approach is runtime.log size (803Kb without fix, 5.4Mb with fix)