From owner-freebsd-arch@FreeBSD.ORG Wed Apr 1 18:00:19 2009 Return-Path: Delivered-To: arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A9821065680; Wed, 1 Apr 2009 18:00:19 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 446D48FC12; Wed, 1 Apr 2009 18:00:18 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.3/8.14.2) with ESMTP id n31I0RHH039722; Wed, 1 Apr 2009 14:00:27 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by zim.MIT.EDU (8.14.3/8.14.2/Submit) id n31I0Q4I039721; Wed, 1 Apr 2009 14:00:26 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Date: Wed, 1 Apr 2009 14:00:26 -0400 From: David Schultz To: Luigi Rizzo Message-ID: <20090401180026.GA39424@zim.MIT.EDU> Mail-Followup-To: Luigi Rizzo , Poul-Henning Kamp , Daniel Eischen , FreeBSD Arch , Tim Kientzle , Marcel Moolenaar References: <20090331064959.GA3516@onelab2.iet.unipi.it> <96314.1238481987@critter.freebsd.dk> <20090331065548.GA3851@onelab2.iet.unipi.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090331065548.GA3851@onelab2.iet.unipi.it> Cc: Daniel Eischen , FreeBSD Arch , Poul-Henning Kamp , Tim Kientzle , Marcel Moolenaar Subject: Re: On errno X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2009 18:00:20 -0000 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.