comparison of different syslog implementations

  • Thread starter Rainer Weikusat
  • Start date
R

Rainer Weikusat

NB: This includes Sys::Syslog because 'it is part of Perl' and doesn't
include Net::Syslog because it is - like Sys::Syslog - really an
alternate syslog client implementation (according to its
documentation), something I'm not really interested in because I want
to use the C libary syslog support.

Timing in this text come from NYTProf running through the 'startup'
phase of a particular program (logs about ~330 messsages on the
verbosity level where it is used 'in production').


Sys::Syslog
-----------

(AFAIK) 'pure Perl' heavy-weight and feature-rich 'syslog client'
which talks 'syslog protocol' to a syslog server reachable via 'some
kind of socket connection'.

The central message logging routine looks like this:

sub msg
{
local $@ if $@;
syslog('notice', @_);
}

It needs to localize $@ because the syslog routine uses eval (AFAIK,
for various tests). On average, it ran for 180us per call.


Unix::Syslog
------------

'Mostly-XS' interface to the syslog routines in the C library. Message
formatting done via sprintf-call in Perl wrapper routine. Supports %m
in the same way as Sys::Syslog (using the same line of code,
actually). The syslog constants are provided as hand-written XS
functions which need to be executed whenever the value of such a
'constant' is needed.

The central message logging routine looks like this:

sub msg
{
syslog(LOG_NOTICE, $_[0], @_[1 .. $#_]);
}

This way of passing arguments is necessary because the syslog-routine
has a prototype of $$@ which implies that it can't work with an array
of arguments encompassing both the format string and the 'data bits'.
On average, it ran for 70us per call, about 2.57 times the speed of
the Sys::Syslog-based routine.


'syslog weekend project'
------------------------

'Minimal' XS-only (for the working code) interface to the syslog
routines in the C library. Message formatting is done via perlapi
call from the XS-code. Does not support %m because the cost of doing
so is IMHO not sensible, compared to the marginal inconvenience of
having to use %s and "$!" as formatting argument for that. The syslog
constants are 'real' Perl constants (no runtime calls to anything
involved) created based on the h2xs 'constant support code' (which
also does runtime functions calls).

The central message logging routine looks like this

sub msg
{
syslog(LOG_NOTICE, @_);
}

On average, it ran for 54us per call, about 3.33 times the speed of
the Sys::Syslog routine and about 1.23 times the speed of the
Unix::Syslog routine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top