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 Bootstrap to pre build faster by using multiple threads #28

Closed
wants to merge 2 commits into from

Conversation

aikar
Copy link
Contributor

@aikar aikar commented Oct 12, 2018

Divide up the work into multiple queues, and send those tasks
back into the executor.

This lets us precache everything concurrently, reducing precache
time by about 75%~ on a typical 8 core system.

Bootstrap time was seen taking up to 30 seconds of time in testing,
which is long enough in Minecraft that data conversions may need to
occur.

This brought it down to about 6-7 seconds.

Divide up the work into multiple queues, and send those tasks
back into the executor.

This lets us precache everything concurrently, reducing precache
time by about 75%~ on a typical 8 core system.

Bootstrap time was seen taking up to 30 seconds of time in testing,
which is long enough in Minecraft that data conversions may need to
occur.

This brought it down to about 6-7 seconds.
List<List<Runnable>> queueList = new ArrayList<>();
List<Runnable> current = new ArrayList<>();
queueList.add(current);
int maxTasks = (int) Math.max(1, Math.floor(allTasks.size() / (float)Math.min(6, Runtime.getRuntime().availableProcessors()-2)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to do -2 on core count to not hog every thread, leaving 1 for game and 1 extra as a max, and an overall cap of 6 for systems with many cores overall.

@aikar
Copy link
Contributor Author

aikar commented Oct 12, 2018

Comparison:
Before:

After:

Copy link
Contributor

@Dinnerbone Dinnerbone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but I'd like @RainWarrior's input too.

@RainWarrior
Copy link
Contributor

#29

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