Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Apr 2009 14:00:26 -0400
From:      David Schultz <das@FreeBSD.ORG>
To:        Luigi Rizzo <rizzo@iet.unipi.it>
Cc:        Daniel Eischen <deischen@FreeBSD.ORG>, FreeBSD Arch <arch@FreeBSD.ORG>, Poul-Henning Kamp <phk@phk.freebsd.dk>, Tim Kientzle <kientzle@FreeBSD.ORG>, Marcel Moolenaar <xcllnt@mac.com>
Subject:   Re: On errno
Message-ID:  <20090401180026.GA39424@zim.MIT.EDU>
In-Reply-To: <20090331065548.GA3851@onelab2.iet.unipi.it>
References:  <20090331064959.GA3516@onelab2.iet.unipi.it> <96314.1238481987@critter.freebsd.dk> <20090331065548.GA3851@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Mar 31, 2009, Luigi Rizzo wrote:
> On Tue, Mar 31, 2009 at 06:46:27AM +0000, Poul-Henning Kamp wrote:
> > In message <20090331064959.GA3516@onelab2.iet.unipi.it>, Luigi Rizzo writes:
> > 
> > >we are probably digressing but printf in glibc has specifiers to
> > >indicate which argument you want to use for each format.
> > >
> > >http://www.gnu.org/software/hello/manual/libc/Output-Conversion-Syntax.html
> > >
> > >I suppose this takes an extra pass over the format string to collect
> > >the proper type info for all arguments, so it is not
> > >not a dramatic change in the implementation of *printf.
> > 
> > Yeah, we have that crap too, and you can see how messy and slow our
> > printf became as a result in SVN.
> 
> I have never run performance tests of printf, but it woudld be
> definitely interesting to figure out how expensive is the parsing
> of the format specifiers.

The expensive part, which accounts for more than 70% of the cost
of processing a format specifier, is gluing together the iovec of
output fragments in stdio and writing to the stream. The actual
parsing accounts for almost none of the cost; it amounts to
scanning for a `%', then using a switch statement (which gcc
compiles into a jump table) to process the specifiers.

Most of the code for handling positional parameters lives in
printf-pos.c, and it's never invoked if you don't use positional
parameters.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090401180026.GA39424>