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

Dynamic Thread Pool #812

Merged
merged 3 commits into from
Apr 27, 2024
Merged

Dynamic Thread Pool #812

merged 3 commits into from
Apr 27, 2024

Conversation

TrueDarkLord
Copy link
Contributor

@TrueDarkLord TrueDarkLord commented Apr 23, 2024

Switched to using a thread pool instead of a single thread to ensure all tasks can be processed. Additionally, a custom checker has been added to resize the core pool size based on the number of tasks, aiming to minimize the creation of unnecessary threads.

If the queue is filled with more than ten thousand processes, it will start to throw errors. Since each thread can handle 100+ per second, this should not be a problem. With one to ten players on the server, the queue with one worker thread tends to stay empty. If the queue is more than 1/5th full while using a single thread, another one is added.

Changes:

  • Changed to Thread Pool
  • Increases base pool size every 5 seconds if tasks build up too much.

Update NBT-API as it seems to be the only thing needed to fully support the coming changes.
Change over to using a thread pool instead of a single thread in order to make sure that all tasks can be processed.
Added a custom checker to re-size the core pool size depending on the amount of tasks in an attempt to reduce the creation of un-needed threads.
@ryderbelserion ryderbelserion changed the base branch from main to ver/1.20.5 April 23, 2024 18:58
@ryderbelserion
Copy link
Member

Changed it to the 1.20.5 branch for the time being, it'll all get merged into main eventually anyway

@TrueDarkLord TrueDarkLord linked an issue Apr 23, 2024 that may be closed by this pull request
3 tasks
@ryderbelserion ryderbelserion changed the base branch from ver/1.20.5 to main April 27, 2024 15:10
@ryderbelserion ryderbelserion changed the base branch from main to ver/1.20.5 April 27, 2024 15:11
@ryderbelserion ryderbelserion merged commit 245d476 into ver/1.20.5 Apr 27, 2024
1 check passed
@ryderbelserion ryderbelserion deleted the Thread-Pool branch April 27, 2024 15:12
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.

CrazyEnchanmets casues crash
2 participants