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

Optimizes player heads by adding a cache #2348

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Zailer43
Copy link

Description

This pull request avoids creating RenderType and getting the skin from the skinmanager every time a player head (inventory, block or placed in the armor slot) was rendered, as they are costly and currently took a similar amount of time as rendering the head itself.

Expected changes

Although, in singleplayer this change should not affect almost anything, in servers or maps where there is a high level of detail and many heads are used it should give a slight improvement, and as you can see in the screenshots below, in general it reduces the micro-stutter.

Spark

These spark tests were run for 30 seconds in the world with a chunk of heads. You can see that where before rendering the heads cost 13396ms it now takes 9000ms

dev branch: https://spark.lucko.me/KDvsr25bBC
this pr: https://spark.lucko.me/Tq8Ek2tpsE

Screenshots

A chunk of heads, worst-case scenario this pr

2024-02-19_13 54 11

dev branch

2024-02-19_14 05 35

Entities with custom player heads

this pr

2024-02-19_13 55 03

dev branch

2024-02-19_14 06 32

A chest full of custom heads

this pr

2024-02-19_13 56 02

dev branch

2024-02-19_14 07 30

Hypixel's worst optimized lobby

this pr

2024-02-19_15 05 21

dev branch

2024-02-19_15 02 20

@Zailer43 Zailer43 marked this pull request as draft February 27, 2024 02:21
@Zailer43
Copy link
Author

Zailer43 commented Feb 27, 2024

Apparently there are moments during 1 or 2 frames heads that had the texture loaded stop having it loaded, I don't understand why and then I should investigate this.

It usually happens in rare situations where the inventory has heads and in one frame all of them lose the skin or an entity that has a head during a frame stops having it.

Edit: now that I think about it, I have only seen this bug on one server, I haven't been playing much on others, but as it happens very rarely (maybe once every 4 hours) I haven't reproduced it on other servers or singleplayer.

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.

1 participant