This benchmark currently hangs when run with $n = 0, $threads = 2 and RESEEDING_THRESHOLD = 1024.
In addition to the two threads spawned by the benchmark code, BenchmarkSharedBufferRng::new spawns another thread (at minimum priority) that reads from OsRng in batches and writes to a bounded crossbeam channel. new_standard_rng creates ReseedingRng instances that try_recv from that channel, only calling OsRng themselves if the channel is empty. The seed-sending thread exits when the rngs are both dropped. Full source code is at https://github.com/Pr0methean/shared_buffer_rng/tree/03e0448033644bce2cd1e8d2f769fd8a8c926681. A version of this benchmark that uses fire-and-forget threads (by replacing ITERATIONS_LEFT with a function-scoped Arc) runs fine, at least when the process runs only one such benchmark.
This benchmark currently hangs when run with
$n
= 0,$threads
= 2 andRESEEDING_THRESHOLD
= 1024.In addition to the two threads spawned by the benchmark code,
BenchmarkSharedBufferRng::new
spawns another thread (at minimum priority) that reads fromOsRng
in batches and writes to a bounded crossbeam channel.new_standard_rng
createsReseedingRng
instances that try_recv from that channel, only callingOsRng
themselves if the channel is empty. The seed-sending thread exits when therngs
are both dropped. Full source code is at https://github.com/Pr0methean/shared_buffer_rng/tree/03e0448033644bce2cd1e8d2f769fd8a8c926681. A version of this benchmark that uses fire-and-forget threads (by replacing ITERATIONS_LEFT with a function-scoped Arc) runs fine, at least when the process runs only one such benchmark.