Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

earliest { ... } uses busy waiting when used with more than one channel, drives CPU usage up to 100% #3630

Closed
p6rt opened this issue Dec 29, 2014 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Dec 29, 2014

Migrated from rt.perl.org#123519 (status was 'resolved')

Searchable as RT123519$

@p6rt
Copy link
Author

p6rt commented Dec 29, 2014

@p6rt
Copy link
Author

p6rt commented Jul 7, 2015

From andreas@andreasvoegele.com

On Mon Dec 29 10​:32​:42 2014, rob@​hoelz.ro wrote​:

See also https://rt-archive.perl.org/perl6/Ticket/Display.html?id=123515

The attached script demonstrates the busy waiting. The script also leaks memory. In the output of top(1) the CPU is always at 100% and DATA grows​:

  PID USER VIRT RES SHR %CPU %MEM TIME+ DATA COMMAND
46088 andreas 256m 98m 19m 100 1.3 0​:03.27 220m moar

  PID USER VIRT RES SHR %CPU %MEM TIME+ DATA COMMAND
46088 andreas 426m 269m 19m 100 3.5 3​:57.15 389m moar

Tested with Rakudo Star Release 2015.06 on Slackware64-current.

@p6rt
Copy link
Author

p6rt commented Jul 7, 2015

@p6rt
Copy link
Author

p6rt commented Jul 7, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 5, 2015

From @jnthn

On Tue Jul 07 13​:44​:33 2015, voegelas wrote​:

On Mon Dec 29 10​:32​:42 2014, rob@​hoelz.ro wrote​:

See also https://rt-archive.perl.org/perl6/Ticket/Display.html?id=123515

The attached script demonstrates the busy waiting. The script also
leaks memory. In the output of top(1) the CPU is always at 100% and
DATA grows​:

PID USER VIRT RES SHR %CPU %MEM TIME+ DATA COMMAND
46088 andreas 256m 98m 19m 100 1.3 0​:03.27 220m moar

PID USER VIRT RES SHR %CPU %MEM TIME+ DATA COMMAND
46088 andreas 426m 269m 19m 100 3.5 3​:57.15 389m moar

Tested with Rakudo Star Release 2015.06 on Slackware64-current.

earliest is gone, in favor of react/whenever, which also works on supplies. I just replaced the earliest loop​:

loop {
  earliest * {
  more $time_channel { say "Time​: $_" }
  more $mpd_channel { say "Song​: $_" }
  }
}

With​:

react {
  whenever $time_channel { say "Time​: $_" }
  whenever $mpd_channel { say "Song​: $_" }
}

And can confirm it works and that the CPU stays at zero while waiting.

Can't really test the CPU usage easily, but that whenever can be used with multiple channels is tested in S17-supply/syntax.t.

@p6rt p6rt closed this as completed Dec 5, 2015
@p6rt
Copy link
Author

p6rt commented Dec 5, 2015

@jnthn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant