Skip to content

Major Performance Optimizations for Standard Ruleset (Android Focus) - #141

Merged
winnerspiros merged 7 commits into
masterfrom
perf/major-android-optimizations-std-14162171825783206919
Apr 3, 2026
Merged

Major Performance Optimizations for Standard Ruleset (Android Focus)#141
winnerspiros merged 7 commits into
masterfrom
perf/major-android-optimizations-std-14162171825783206919

Conversation

@google-labs-jules

Copy link
Copy Markdown

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)

  1. Slider Path Search: Optimized SliderPath.GetPathToProgress (used for slider snaking) from $O(N)$ to $O(\log N)$ using binary search on cumulative lengths. This significantly reduces CPU load on maps with very long sliders.
  2. FollowPoint Loading: Optimized FollowPointRenderer by moving the Comparer in addEntry to a static field, reducing allocations during map load.
  3. Judgement Logic: Replaced LINQ .Count() and .Any() calls with manual for loops in DrawableSlider.CheckForResult to eliminate per-judgement enumerator allocations.
  4. Sample Loading: Removed redundant .Cast<ISampleInfo>().ToArray() calls in DrawableHitObject and DrawableSlider where the source collection is already suitable.
  5. Repeat Rotation: Improved the search logic in DrawableSliderRepeat.UpdateSnakingPosition to be more direct.

Android-Specific Optimizations (Gated by RuntimeInfo.Platform.Android)

  1. Slider Snaking Throttling: Implemented a frame-based and progress-delta-based throttling mechanism in SnakingSliderBody to reduce the frequency of GPU vertex uploads.
  2. Judgement Simplification: Simplified hit lighting animations in DrawableOsuJudgement to reduce the transform load on the render thread.
  3. Update Loop Early-Out: Added a LifetimeStart/LifetimeEnd check in DrawableHitObject.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

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.
@google-labs-jules

Copy link
Copy Markdown
Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

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;
Comment on lines +161 to +170
{
// 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.
@winnerspiros
winnerspiros merged commit ef0469b into master Apr 3, 2026
5 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants