Skip to content

Conversation

@jojoe77777
Copy link

@jojoe77777 jojoe77777 commented Nov 14, 2024

Each time ChunkBuilder.startWorkers() is called, which happens on each f3+f, a certain number of Chunk Render Task Executor threads are created. By default this is Runtime.getRuntime().availableProcessors(), which results in 32 render threads constantly being recreated for CPUs with 32 logical processors. Reducing this number to 1 significantly improves performance of F3+F, with no obvious impact on rendering performance. An option for 1-32 has been added to the settings, but I suspect the default of 1 will be optimal for everyone. Upstream logic for calculating default thread count has been added, users can choose to override

@contariaa
Copy link
Member

This option exists upstream aswell, we should probably name it Chunk Update Threads like they do to keep things consistent and avoid any confusion.
I am highly sceptical of 1 worker thread making no difference compared to 32, id rather just copy the "optimal thread count" calculation from upstream: https://github.com/CaffeineMC/sodium/blob/dev/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/executor/ChunkBuilder.java#L136-L151

Another idea to consider would be whether it is even necessary for sodium to create new chunks everytime, although its probably not worth the effort if it can be fixed by just lowering threads to reasonable values.

@contariaa
Copy link
Member

Changes look good, only things I'd still want to do would be renaming the option to match upstream and moving it into the advanced category

@DesktopFolder
Copy link

This completely fixes the F3+F lag spikes for me, from 3-5s lag spikes when replicating the issue to no perceptible lag whatsoever.

@tildejustin tildejustin merged commit 9a37e42 into Minecraft-Java-Edition-Speedrunning:1.16.1 Dec 25, 2024
1 check 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.

4 participants