Hello there,

I noticed with strace that a simple Hello World mojo lite app (perl -Ilib/
-Mojo -E 'a("/" => {text => "test\n"})->start' daemon) has one of the most
common syscall is gettimeofday.

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 39.95    0.000614           0      5610           write
 22.12    0.000340           0     11238           gettimeofday
 15.35    0.000236           0     22720           clock_gettime
  5.92    0.000091           0     11220           epoll_wait
  5.66    0.000087           0      5666           read
  5.53    0.000085           0     11220           epoll_ctl
  5.47    0.000084           0     11220           getsockname
  0.00    0.000000           0        56           close
  0.00    0.000000           0       112       112 lseek
  0.00    0.000000           0       112       112 ioctl
  0.00    0.000000           0       112        56 accept
  0.00    0.000000           0        56           getpeername
  0.00    0.000000           0        56           setsockopt
  0.00    0.000000           0       168           fcntl
------ ----------- ----------- --------- --------- ----------------
100.00    0.001537                 79566       280 total
​

These calls are used here:
https://github.com/kraih/mojo/blob/bbc6e0c21480d2594f518e85ad331bfa795eb430/lib/Mojolicious.pm#L119
and
https://github.com/kraih/mojo/blob/bbc6e0c21480d2594f518e85ad331bfa795eb430/lib/Mojolicious/Controller.pm#L207.
And
they are needed only in the debug mode, but used even in production mode,
where log level is info and above.

Without this extra Time::HiRes::gettimeofday calls performance of this app
can be increased to 10% (from 1100rps to 1230rps on my laptop).

I can't create a PR because a simple check for $log->is_level('debug')
breaks the tests t/mojolicious/app.t and other, where app->log->level is
debug, but $log->is_level('debug') return false. (I think this is due
HARNESS_IS_VERBOSE environment variable)

So if anyone can help with PR it would be nice.

-- 
Andrey Khozov

-- 
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