Skip to content

Fix performance regressions with buffer uploads in 1.21.5 #3094

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

Open
wants to merge 1 commit into
base: 1.21.5/stable
Choose a base branch
from

Conversation

AzureAaron
Copy link

This PR essentially reverts Mojang's changes to buffer uploading in 1.21.5 where the new method of uploading buffer data via glBufferSubData is inefficient and causes significant performance losses across some systems (see MC-295893 for further details).

This patch on my system (macOS) pretty much fixes the significant performance loss I've experienced from this update. I'm not sure if the patch should only be applied to certain systems or not given the many users reporting performance losses (which may or may not be related to this) so that might be something worth considering.

I believe I have added the mixins and whatnot correctly, if anything needs changing please let me know. I also had to update MixinExtras for the @Cancellable annotation (Fabric and Neo ship this version so it should be fine).

@djmrFunnyMan
Copy link

I'm seeing up to a 8% performance drop in 1.21.5 on my Ryzen 7600X + Intel B580 system. This pr does not remedy that at all.

However interestingly enough it brings GPU utilization way down to what it was in 1.21.4 (80-50% in 0.6.12, 20-40% with this patch)

@BlueGradientHorizon
Copy link

BlueGradientHorizon commented Apr 1, 2025

On my laptop, r5 4600h + gtx1650m it seems that this PR sadly does not affect FPS in any way. For me, GPU utilization always has been at 99-100% w/shaders and 30-50% w/o on 1.21.4 and is the same on 1.21.5, but with lower FPS. I'm experiencing a ~30 FPS drop in general compared to 1.21.4, both with Sodium only and Sodium+Iris. If you need any additional info, let us know.

@djmrFunnyMan
Copy link

djmrFunnyMan commented Apr 1, 2025

With Iris shaders on this PR introduced insane frametime instability
2025-04-01_19 42 09
2025-04-01_19 39 36

It also does nothing to fix the regressions (20% lower FPS since 1.21.4)
2025-04-01_19 43 43

@BlueGradientHorizon
Copy link

BlueGradientHorizon commented Apr 1, 2025

insane frametime instability

For me the frametime graph itself is perfectly fine, and I also use Complementary shader. Maybe driver-specific problem arised?

@djmrFunnyMan
Copy link

Here's some spark profiles:

Release Sodium: https://spark.lucko.me/88dmo9pZvH
This Patch: https://spark.lucko.me/MvAPNsiJZj

@douira
Copy link
Collaborator

douira commented Apr 1, 2025

Testing Sodium's 1.21.4/stable and 1.21.5/stable branches and this PR I wasn't able to find a change in any direction beyond measurement noise on my macOS system. (intel 10900K, RX 6900 XT) It should be noted that my hardware configuration is very uncommon. (deleted my previous comment due to measurement error)

@mrjasonn
Copy link

mrjasonn commented Apr 2, 2025

Testing Sodium's 1.21.4/stable and 1.21.5/stable branches and this PR I wasn't able to find a change in any direction beyond measurement noise on my macOS system. (intel 10900K, RX 6900 XT) It should be noted that my hardware configuration is very uncommon. (deleted my previous comment due to measurement error)

@douira Maybe try testing with lots of entitys, for example, Hypixel bedwars lobby 1

@douira
Copy link
Collaborator

douira commented Apr 5, 2025

I've tested this with 1662 item frames and I can in fact now measure a fps regression between the 1.21.4/stable and 1.21.5/stable branches (75 fps down to 57 fps). However, applying this patch makes it worse, it goes down to 51 fps.

1.21.4/stable:
1 21 4 stable

1.21.5/stable:
1 21 5 stable

this patch:
1 21 5 3094 patch

@mrjasonn
Copy link

mrjasonn commented Apr 5, 2025

I've tested this with 1662 item frames and I can in fact now measure a fps regression between the 1.21.4/stable and 1.21.5/stable branches (75 fps down to 57 fps). However, applying this patch makes it worse, it goes down to 51 fps.

1.21.4/stable: 1 21 4 stable

1.21.5/stable: 1 21 5 stable

this patch: 1 21 5 3094 patch

@douira Oh! I have noticed that even on a Mac, you're not using an Apple designed GPU. You will notice the performance difference with the many entities on an Apple designed GPU, as fast buffer upload actually makes Apple GPUs lag.

@mrjasonn
Copy link

mrjasonn commented Apr 7, 2025

@douira go see RaphiMC/ImmediatelyFast#279, it may give some useful information on this, as ImmediatelyFast also had their fast buffer upload optimisation enabled for Apple GPUs at some point before Mojang added it themselves.

@Kalanyr
Copy link

Kalanyr commented Apr 16, 2025

I definitely have the performance regression issue ( about 75% FPS for 1.21.5 vs 1.21.4 ) and while this has an effect it's pretty minor ( it's roughly x1.1 FPS on 1.21.5 as compared to without it ) so I don't think this is the actual major cause of regression at least for my setup.

@djmrFunnyMan
Copy link

@Kalanyr what is your setup?

@Kalanyr
Copy link

Kalanyr commented Apr 16, 2025 via email

@RaphiMC
Copy link

RaphiMC commented May 19, 2025

Hello, ImmediatelyFast dev here.
The buffer upload regression in 1.21.5 does not affect all systems. It mostly affects Apple GPUs. Avoiding glBufferSubData on all systems causes a performance decrease on most GPU drivers. ImmediatelyFast <=1.21.4 in fact even has an optimization which replaces glBufferData with glBufferSubData because its measureable faster on most systems. I although had a check, which checked for an Apple GPU and then don't apply that optimization because Apple's OpenGL driver is horribly optimized. I have now added a fix for the buffer upload regression in ImmediatelyFast 1.21.5: RaphiMC/ImmediatelyFast@f6de9a6 (Release 1.9.4)

It should be noted that 1.21.5 has multiple other performance regressions, even ones which affect all GPU vendors, so direct comparisons between 1.21.4 and 1.21.5 even with the buffer upload fix are not possible.

@BlueGradientHorizon
Copy link

1.21.5 has multiple other performance regressions

I just don't understand how mojang could release such a completely broken update... Almost the same set of mods of the latest versions (at the moment), the same set of resource packs, the same shader with the same settings, and the difference is -50% frames.

1 21 4
1 21 5

But what's more frightening is that some mod developers are already stopping support for 1.21.4 or are moving it to the category of receiving only critical updates.

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.

7 participants