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

Optimize Thread Wait Logic in BlockableEventLoop #69

Merged
merged 5 commits into from
Jun 15, 2024

Conversation

HaHaWTH
Copy link
Member

@HaHaWTH HaHaWTH commented Jun 14, 2024

This PR should fix MC-183518. The current implementation in BlockableEventLoop involves yielding the thread before parking, which is unnecessary and can lead to inefficient thread scheduling and higher CPU usage.

Changes made:

  • Replaced the existing thread yielding logic with LockSupport.parkNanos to directly park the thread for 2 milliseconds.

Reasoning:
Yielding the thread is redundant if the thread is about to be parked immediately afterward.

Reference:

This change optimizes the way SurfaceRules update their biome supplier,avoiding unnecessary object creations and thus reducing memory allocations
during world generation. The update method now reuses the existingPositionalBiomeGetter object if it's already present, otherwise it
initializes a new one.

Additionally, the tryApply method in SurfaceRules now avoids iterator
allocation by directly accessing the rules list, which further contributes
to reducing garbage collection pressure during world generation.
@HaHaWTH HaHaWTH requested a review from Dreeam-qwq June 14, 2024 22:29
@Dreeam-qwq
Copy link
Member

GO

@Dreeam-qwq Dreeam-qwq merged commit 090f29e into Winds-Studio:ver/1.20.6 Jun 15, 2024
1 check passed
@HaHaWTH HaHaWTH deleted the ver/1.20.6 branch October 20, 2024 18:14
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