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

Use ThreadLocalRandom #581

Merged
merged 2 commits into from Oct 29, 2017

Conversation

Projects
3 participants
@PickNChew
Member

PickNChew commented Oct 25, 2017

This PR removes most local instantiations of Random and replaces it with ThreadLocalRandom. This will improve performance and get rid of the random Random instances that are scattered everywhere.

@mastercoms

This comment has been minimized.

Member

mastercoms commented Oct 25, 2017

This is nice, thank you for your work. However, I'm not sure about replacing the world's random instance. Are there any downsides to the world's random generation possibly not sharing the same seed?

Also, just to make sure, did you replace any random instances with a specific seed?

@PickNChew

This comment has been minimized.

Member

PickNChew commented Oct 25, 2017

I purposely did not change the world generation side of things. Most random's that were changed did not have seeds set. However, a few of them I found was not useful.

@mastercoms

This comment has been minimized.

Member

mastercoms commented Oct 25, 2017

Sorry for the confusion, when I said "world random generation", I didn't mean world generation, but rather the generation of random values within the GlowWorld class, previously generated by a single Random instance. Does it matter that these cases have no guarantee of sharing the same seed?

@PickNChew PickNChew force-pushed the PickNChew:master branch from f2968b5 to db4d6e9 Oct 25, 2017

@PickNChew

This comment has been minimized.

Member

PickNChew commented Oct 25, 2017

From what I could tell, no. It does not matter. ThreadLocalRandom generates only 1 seed and it's shared across the thread.

@momothereal momothereal added this to Review in 2017Q4 Oct 28, 2017

@momothereal

Reviewed and approved by @kamcio96

@momothereal momothereal merged commit 1387290 into GlowstoneMC:master Oct 29, 2017

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
license/cla Contributor License Agreement is signed.
Details

@momothereal momothereal moved this from Review to Completed in 2017Q4 Oct 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment