Major Performance Optimizations for Standard Ruleset (Android Focus) - #141
Conversation
Generic Optimizations: - Optimized `SliderPath.GetPathToProgress` from O(N) to O(log N) using binary search on cumulative lengths. - Optimized `DrawableSlider.CheckForResult` by replacing LINQ calls with manual loops. - Optimized `FollowPointRenderer` by using a static comparer to reduce allocations. - Optimized `LoadSamples` in `DrawableHitObject` and `DrawableSlider` to eliminate redundant array allocations. - Improved `DrawableSliderRepeat.UpdateSnakingPosition` rotation search logic. Android-Specific Optimizations: - Implemented vertex re-calculation throttling in `SnakingSliderBody` to reduce CPU/GPU overhead. - Added `Update()` early-out in `DrawableHitObject` for inactive objects. - Simplified hit lighting animations in `DrawableOsuJudgement` to reduce render thread load.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Generic: - Optimized SliderPath.GetPathToProgress from O(N) to O(log N). - Replaced LINQ in DrawableSlider judgement logic with manual loops. - Moved FollowPointRenderer comparer to a static field. - Reduced allocations in LoadSamples by removing redundant Cast<T>(). Android: - Implemented SnakingSliderBody update throttling. - Added DrawableHitObject.Update() early-out for inactive objects. - Simplified hit lighting animations in DrawableOsuJudgement.
Generic: - Optimized SliderPath.GetPathToProgress from O(N) to O(log N). - Replaced LINQ in DrawableSlider judgement logic with manual loops. - Moved FollowPointRenderer comparer to a static field. - Reduced allocations in LoadSamples by removing redundant Cast<T>(). Android: - Implemented SnakingSliderBody update throttling. - Added DrawableHitObject.Update() early-out for inactive objects. - Simplified hit lighting animations in DrawableOsuJudgement. CI/Cleanup: - Fixed missing/incorrect file headers and BOMs. - Cleaned up redundant using directives and normalized line endings.
Generic: - Optimized SliderPath.GetPathToProgress from O(N) to O(log N). - Replaced LINQ in DrawableSlider judgement logic with manual loops. - Moved FollowPointRenderer comparer to a static field. - Reduced allocations in LoadSamples by removing redundant Cast<T>(). Android: - Implemented SnakingSliderBody update throttling. - Added DrawableHitObject.Update() early-out for inactive objects. - Simplified hit lighting animations in DrawableOsuJudgement. CI/Formatting: - Restored standard copyright headers and UTF-8 BOM. - Fixed indentation in DrawableHitObject.cs and normalized usings.
Generic: - Optimized SliderPath.GetPathToProgress from O(N) to O(log N). - Replaced LINQ in DrawableSlider judgement logic with manual loops. - Moved FollowPointRenderer comparer to a static field. - Reduced allocations in LoadSamples by removing redundant Cast<T>(). Android: - Implemented SnakingSliderBody update throttling. - Added DrawableHitObject.Update() early-out for inactive objects. - Simplified hit lighting animations in DrawableOsuJudgement. CI/Formatting: - Corrected indentation in DrawableHitObject.UpdateState to match project style. - Normalized headers, line endings, and BOMs across all modified files.
| using osu.Game.Rulesets.Scoring; | ||
| using osu.Game.Skinning; | ||
|
|
||
| using JetBrains.Annotations; |
|
|
||
| Samples.Samples = HitObject.TailSamples.Cast<ISampleInfo>().ToArray(); | ||
| slidingSample.Samples = HitObject.CreateSlidingSamples().Cast<ISampleInfo>().ToArray(); | ||
| Samples.Samples = HitObject.TailSamples.ToArray(); |
| Samples.Samples = HitObject.TailSamples.Cast<ISampleInfo>().ToArray(); | ||
| slidingSample.Samples = HitObject.CreateSlidingSamples().Cast<ISampleInfo>().ToArray(); | ||
| Samples.Samples = HitObject.TailSamples.ToArray(); | ||
| slidingSample.Samples = HitObject.CreateSlidingSamples().ToArray(); |
| using osu.Game.Skinning; | ||
| using osuTK; | ||
|
|
||
| using JetBrains.Annotations; |
| { | ||
| // Throttle updates on Android to save CPU/GPU cycles during snaking. | ||
| // We only update every 2nd frame if the progress delta is small. | ||
| if (lastUpdateTime > 0 && Clock.CurrentTime - lastUpdateTime < 16) | ||
| { | ||
| double delta = Math.Max(Math.Abs(p0 - (SnakedStart ?? 0)), Math.Abs(p1 - (SnakedEnd ?? 0))); | ||
| if (delta < 0.005) return; | ||
| } | ||
| lastUpdateTime = Clock.CurrentTime; | ||
| } |
| if (lastUpdateTime > 0 && Clock.CurrentTime - lastUpdateTime < 16) | ||
| { | ||
| double delta = Math.Max(Math.Abs(p0 - (SnakedStart ?? 0)), Math.Abs(p1 - (SnakedEnd ?? 0))); | ||
| if (delta < 0.005) return; |
| double delta = Math.Max(Math.Abs(p0 - (SnakedStart ?? 0)), Math.Abs(p1 - (SnakedEnd ?? 0))); | ||
| if (delta < 0.005) return; | ||
| } | ||
| lastUpdateTime = Clock.CurrentTime; |
| using osu.Game.Screens.Play; | ||
| using osu.Game.Skinning; | ||
|
|
||
| using JetBrains.Annotations; |
| return; | ||
|
|
||
| Samples.Samples = samples.Cast<ISampleInfo>().ToArray(); | ||
| Samples.Samples = samples; |
|
|
||
| using osu.Game.Rulesets.Objects.Types; | ||
|
|
||
| using Newtonsoft.Json; |
Generic: - Optimized SliderPath.GetPathToProgress from O(N) to O(log N). - Replaced LINQ in DrawableSlider judgement logic with manual loops. - Moved FollowPointRenderer comparer to a static field. - Reduced allocations in LoadSamples by removing redundant Cast<T>(). Android: - Implemented SnakingSliderBody update throttling. - Added DrawableHitObject.Update() early-out for inactive objects. - Simplified hit lighting animations in DrawableOsuJudgement. CI/Formatting: - Corrected indentation to use tabs in modified files. - Ensured consistent file headers and UTF-8 BOM encoding.
…g fix) Generic: - Optimized SliderPath.GetPathToProgress from O(N) to O(log N). - Replaced LINQ in DrawableSlider judgement logic with manual loops. - Moved FollowPointRenderer comparer to a static field. - Reduced allocations in LoadSamples by removing redundant Cast<T>(). Android: - Implemented SnakingSliderBody update throttling. - Added DrawableHitObject.Update() early-out for inactive objects. - Simplified hit lighting animations in DrawableOsuJudgement. CI/Formatting: - Standardized all indentation to spaces (4 spaces per level) to satisfy IDE0055. - Verified consistent file headers and UTF-8 BOM encoding.
This PR implements several major performance optimizations for the osu! Standard ruleset, with a particular focus on improving the experience on Android devices.
The optimizations range from generic algorithmic improvements to platform-specific throttling mechanisms:
Generic Optimizations (All Platforms)
SliderPath.GetPathToProgress(used for slider snaking) fromFollowPointRendererby moving theComparerinaddEntryto a static field, reducing allocations during map load..Count()and.Any()calls with manualforloops inDrawableSlider.CheckForResultto eliminate per-judgement enumerator allocations..Cast<ISampleInfo>().ToArray()calls inDrawableHitObjectandDrawableSliderwhere the source collection is already suitable.DrawableSliderRepeat.UpdateSnakingPositionto be more direct.Android-Specific Optimizations (Gated by
RuntimeInfo.Platform.Android)SnakingSliderBodyto reduce the frequency of GPU vertex uploads.DrawableOsuJudgementto reduce the transform load on the render thread.LifetimeStart/LifetimeEndcheck inDrawableHitObject.Update()to skip logic for hit objects that aren't currently active, which is particularly effective in high-object-count maps.These changes collectively aim to increase FPS and reduce frame-time jitter (stutters) on mobile hardware while maintaining visual parity where possible.
PR created automatically by Jules for task 14162171825783206919 started by @winnerspiros