mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
prevent cache thrashing (#20129)
* prevent cache thrash Co-authored-by: Charles Blake <cb@cblake.net> * Update lib/pure/random.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: Charles Blake <cb@cblake.net> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
@@ -188,8 +188,10 @@ proc skipRandomNumbers*(s: var Rand) =
|
||||
|
||||
proc randomSum(params: tuple[r: Rand, index: int]) {.thread.} =
|
||||
var r = params.r
|
||||
var s = 0 # avoid cache thrashing
|
||||
for i in 1..numbers:
|
||||
vals[params.index] += r.rand(0..10)
|
||||
s += r.rand(0..10)
|
||||
vals[params.index] = s
|
||||
|
||||
var r = initRand(2019)
|
||||
for i in 0..<thr.len:
|
||||
|
||||
Reference in New Issue
Block a user