On 29.12.2014 13:44, Elizabeth Mattijsen wrote:
On 29 Dec 2014, at 03:05, Rob Hoelz (via RT) <perl6-bugs-follo...@perl.org>
wrote:
# New Ticket Created by Rob Hoelz
# Please include the string: [perl #12351]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=123515 >
See the attached script. When running the script, CPU usage (as reported by top) is
very high.<supply-cpu-test.p6>
Looking deeper into the code, this appears to be caused by the implementation
of “earliest” (former “winner”), which basically does a Thread.yield():
loop { Thread.yield }
This also eats 100% of one CPU. Not sure whether this is intended behaviour of
Thread.yield or not.
yield just tells the scheduler to prefer another thread; if no other
thread has work to do, it'll re-enter the thread that called yield,
causing 100% CPU usage.
Having to use Thread.yield in “earliest” may also be sub-optimal.
Agreed.
Cheers,
Moritz