Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4622

ruby: multithreading in a docker container does not work

$
0
0

I tested ractors in ruby with docker and without

this is my script

ractors = []Benchmark.bm do |x|  x.report("Single thread:") do    cpu_intensive_task    cpu_intensive_task  end   x.report("Two ractors:") do     2.times do       ractors << Ractor.new { cpu_intensive_task }     end     ractors.each(&:take)   endend

when I run it local I see

       user     system      total        realSingle thread:  0.938003   0.000150   0.938153 (  0.942506)Two ractors:  1.177639   0.000387   1.178026 (  0.592312)

but when I run it docker container I see

       user     system      total        realSingle thread:  1.221073   0.000000   1.221073 (  1.221220)Two ractors:  2.448438   0.000995   2.449433 (  1.314552)

how to see real multithreading in docker?

I tried to configure my container with command like a

docker run --rm -it -v `pwd`:/app --memory="1g" --memory-swap="1g" --cpus="4" --ipc='shareable' ruby bash

but nothing helps.


Viewing all articles
Browse latest Browse all 4622


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>