Skip Menu |
Report information
Id: 130370
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: alex.jakimenko [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [CONC] Tapping on a very active .out of Proc::Async wrecks the work queue
Download (untitled) / with headers
text/plain 728b
This is probably best demonstrated by a code snippet. Code: my $out = Channel.new; #my $proc = Proc::Async.new(‘perl6’, ‘-e’, ‘sleep ∞’); # ← this works my $proc = Proc::Async.new(‘perl6’, ‘-e’, ‘.say for 0..0x1FFFF’); # ← this doesn't $proc.stdout.tap({ $out.send: 1 }); my $promise = $proc.start; say ‘let's await ’, now; await Promise.anyof(Promise.in(1), $promise); say ‘let's close ’, now; $proc.kill; await $promise; $out.close; say ‘that's it ’, now; The idea is that we want to kill our process if it is still working after 1 second. This works fine, unless the process is writing a lot of stuff to stdout. IRC log: https://irclog.perlgeek.de/perl6/2016-12-18#i_13760994
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Sun, 18 Dec 2016 06:24:38 -0800, alex.jakimenko@gmail.com wrote: Show quoted text
> This is probably best demonstrated by a code snippet. > > Code: > > my $out = Channel.new; > #my $proc = Proc::Async.new(‘perl6’, ‘-e’, ‘sleep ∞’); # ← this works > my $proc = Proc::Async.new(‘perl6’, ‘-e’, ‘.say for 0..0x1FFFF’); # ← > this doesn't > $proc.stdout.tap({ $out.send: 1 }); > > my $promise = $proc.start; > say ‘let's await ’, now; > await Promise.anyof(Promise.in(1), $promise); > say ‘let's close ’, now; > $proc.kill; > await $promise; > $out.close; > say ‘that's it ’, now; > > > The idea is that we want to kill our process if it is still working > after 1 second. This works fine, unless the process is writing a lot > of stuff to stdout. >
At present, the default scheduler has a single work queue, and if the output from the process is not being processed at the rate it's coming in then the queue will end up with a backlog, and the timer event - placed into the same queue - will be delayed. In the future, we'll get around to having a smarter scheduler. In the meantime, I suggest creating a second scheduler to use for timer (or Proc::Async) events. /jnthn
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.3k
On Tue, 20 Dec 2016 05:07:57 -0800, jnthn@jnthn.net wrote: Show quoted text
> On Sun, 18 Dec 2016 06:24:38 -0800, alex.jakimenko@gmail.com wrote:
> > This is probably best demonstrated by a code snippet. > > > > Code: > > > > my $out = Channel.new; > > #my $proc = Proc::Async.new(‘perl6’, ‘-e’, ‘sleep ∞’); # ← this works > > my $proc = Proc::Async.new(‘perl6’, ‘-e’, ‘.say for 0..0x1FFFF’); # ← > > this doesn't > > $proc.stdout.tap({ $out.send: 1 }); > > > > my $promise = $proc.start; > > say ‘let's await ’, now; > > await Promise.anyof(Promise.in(1), $promise); > > say ‘let's close ’, now; > > $proc.kill; > > await $promise; > > $out.close; > > say ‘that's it ’, now; > > > > > > The idea is that we want to kill our process if it is still working > > after 1 second. This works fine, unless the process is writing a lot > > of stuff to stdout. > >
> At present, the default scheduler has a single work queue, and if the > output from the process is not being processed at the rate it's coming > in then the queue will end up with a backlog, and the timer event - > placed into the same queue - will be delayed. In the future, we'll get > around to having a smarter scheduler. In the meantime, I suggest > creating a second scheduler to use for timer (or Proc::Async) events. >
The new scheduler has a separate queue for time-based events, and seems to do notably better at this.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org