作者:蘑菇雪雪_585 | 来源:互联网 | 2023-10-10 10:24
This question already has an answer here:
这个问题在这里已有答案:
- Does ruby have real multithreading? 9 answers
- ruby有真正的多线程吗? 9个答案
I'm using ruby-head and Debian wheezy x64. When I run a multithreaded ruby script, htop shows that it's using multiple cores visually with the bars at the top, and that it's using 100% CPU on the process list but it's only using 100% of the capacity of one core. I assume it's possible to have multiple cores running at 100% and this number seems too convenient to be bottle-necked by either the program logic or another hardware aspect. Is the OS limiting the amount of available instructions I'm using, if so how do I stop this?
我正在使用ruby-head和Debian wheezy x64。当我运行多线程ruby脚本时,htop显示它在视觉上使用多个核心,顶部有条形图,并且它在进程列表中使用100%CPU,但它只使用100%的一个核心容量。我认为有可能让多个内核以100%运行,这个数字似乎太方便了,无法通过程序逻辑或其他硬件方面进行瓶颈。操作系统是否限制了我正在使用的可用指令数量,如果是这样,我该怎么做呢?
EDIT more info:
编辑更多信息:
When I mean visually using multiple cores e.g.: 47% core 1, 29% core 2, and 24% core 3. These percentages are constantly shifting up and down and to different sets of cores, but always collectively add up to 100%-102%. More than 3(/8 total) cores are being used, but any cores other than the three most burdened only utilize 2% or less capacity. I guess I should also mention this is a linode VPS.
当我的意思是直观地使用多个核心时,例如:47%核心1,29%核心2和24%核心3.这些百分比不断地上下移动到不同的核心集合,但总是总计达到100%-102 %。使用的核心数超过3个(每个/ 8个),但除了三个核心以外的任何核心仅使用2%或更少的容量。我想我还应该提一下这是一个linode VPS。
EDIT:
编辑:
Well it looks like I was reading promises that 2.0 would feature true parallel threads, and not actual release information. Time to switch to Jruby...
好吧,看起来我正在阅读承诺2.0将具有真正的并行线程,而不是实际的发布信息。是时候切换到Jruby ......
2 个解决方案