All,

I was doing some stress testing for an embedded app that sends lots of 
websocket messages, and I can't understand some odd behaviour. Basically mojo 
stalls using 100% CPU for many seconds. Doing the following (to simulate heavy 
load):

         for (1..10000) {
           $sc->{websocket}->send({text => $payload});
         }

Will send 10000 messages to the client (they all arrive) but then mojo stalls 
using 100% CPU for 19 seconds or so. Running nytprof, I get this:

10000   1       1       19.2s   19.2s   Mojo::EventEmitter::unsubscribe

50      10000   3.89ms                  if ($cb) {
51      10000   19.1s                   $self->{events}{$name} = [grep { $cb ne 
$_ } @{$self->{events}{$name}}];
52      10000   9.66ms                  delete $self->{events}{$name} unless 
@{$self->{events}{$name}};

Looking at the above code it seems to suggest that a callback is being used, 
but I am not sure where/how it was created? I do use the following paradigm in 
my code, could this be the cause of the problem?

my $id = Mojo::IOLoop->client({address => '127.0.0.1', port => 5001} => sub {
  my ($loop, $err, $stream) = @_;
  ...
  $stream->on(read => sub {
    my ($stream, $bytes) = @_;
    # Process input
    ...
    [call a function that would send these 10000 messages to the websocket]
  });
});

Thanks,


-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to