GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — gh-118392: Update genrand_uint32 to use atomic operation by corona10 · Pull Request #118393 · python/cpython Conversation
|
|
@pitrou @colesbury cc @rhettinger |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| int index = FT_ATOMIC_LOAD_INT(self->index); | ||
| if (index >= N) { /* generate N words at one time */ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work well. This can end up returning the same generated numbers to different threads, which we don't want.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hmm in that case, should we change the algorithm(thread-safe one) or fine-grained locking for this use case?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a simple fix to the random module.
I commented on the issue. It'd be helpful to document the behavior and provide alternatives. For example, Java's java.util.Random includes the following comment:
Instances of java.util.Random are threadsafe. However, the concurrent use of the same java.util.Random instance across threads may encounter contention and consequent poor performance. Consider instead using ThreadLocalRandom in multithreaded designs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I commented on the issue. It'd be helpful to document the behavior and provide alternatives. For example, Java's java.util.Random includes the following comment:
Okay sounds acceptable :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.