# Poor performance on cluster multithreading

**URL:** <https://discourse.julialang.org/t/poor-performance-on-cluster-multithreading/12248>\
**Category:** Performance\
**Tags:** performance, parallel, multithreading, cluster\
**Created:** [July 8, 2018, 1:09pm UTC](https://discourse.julialang.org/t/poor-performance-on-cluster-multithreading/12248 "2018-07-08T13:09:12Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [July 8, 2018, 9:46pm UTC](https://discourse.julialang.org/t/poor-performance-on-cluster-multithreading/12248/18 "2018-07-08T21:46:20Z")

</div>

Actually there are two problems with this code:

1. `MersenneTwister()` does not ensure that PRNGs are non-overlapping (although the risk of overlap is very small - but this is the reason why `randjump` is provided)
2. The simplest you can do is either do `deepcopy` in each thread an element used by this thread of an array of initiated PRNGs in a single thread or use a “separator” object (one PRNG that is discarded to separate data in threads) similarly to what I proposed in [KissThreading.jl/KissThreading.jl at master · mohamed82008/KissThreading.jl · GitHub](https://github.com/bkamins/KissThreading.jl/blob/master/src/KissThreading.jl#L7). The discarding approach might not be best if you have [NUMA](https://en.wikipedia.org/wiki/Non-uniform_memory_access) issues in your infrastructure.

---

_[View the full topic](https://discourse.julialang.org/t/poor-performance-on-cluster-multithreading/12248)._
