From dev-return-25245-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Mon Apr 1 14:06:18 2013 Return-Path: X-Original-To: apmail-apr-dev-archive@www.apache.org Delivered-To: apmail-apr-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6BE47F94E for ; Mon, 1 Apr 2013 14:06:18 +0000 (UTC) Received: (qmail 75947 invoked by uid 500); 1 Apr 2013 14:06:17 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 75501 invoked by uid 500); 1 Apr 2013 14:06:11 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 75482 invoked by uid 99); 1 Apr 2013 14:06:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Apr 2013 14:06:11 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of trawick@gmail.com designates 209.85.217.179 as permitted sender) Received: from [209.85.217.179] (HELO mail-lb0-f179.google.com) (209.85.217.179) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Apr 2013 14:06:05 +0000 Received: by mail-lb0-f179.google.com with SMTP id t1so1962490lbd.10 for ; Mon, 01 Apr 2013 07:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=OMOF5Z+lX5I4Zkl60zNnXpUbg8Pl5QLSy0iT/lGnkhI=; b=uYJUkAjWscXEmsvU8JSlIKmCmRgTndZGc9Z/0IGDPCXKF6QQN64pBZIrjpYNYThuuf resClcZLVg6wAlMnbTQsIxUwawEAKd4Xl52x5Abg39K77NV2xUcfzqueoEFpMHr2z/V6 Aw2RMk7UKqe0pua1lKpwPqEVw9fOhFKMLC58SI2FifY+nnPAFBDMH0+2WF4mOio6vn++ A+WZ+7XBId48nzdqcCtVPn4ZFlv994mwY5wq16pnARHNFFhwNUqG645POvuqt1Aq3bR5 fFp8kOTsRTBhDzT49Ckx0SzwdeFME/75vwAgQvKaDlVbxNZcCoShamnhVA8kEcSQAhyl BvGg== MIME-Version: 1.0 X-Received: by 10.112.136.33 with SMTP id px1mr5859835lbb.95.1364825145103; Mon, 01 Apr 2013 07:05:45 -0700 (PDT) Received: by 10.114.65.1 with HTTP; Mon, 1 Apr 2013 07:05:44 -0700 (PDT) In-Reply-To: <51595F93.70604@wanadoo.fr> References: <201303281838.30421.sf@sfritsch.de> <51595F93.70604@wanadoo.fr> Date: Mon, 1 Apr 2013 10:05:44 -0400 Message-ID: Subject: Re: [PATCH] Reduce apr_[i|l|off_t_]toa memory footprint for common cases From: Jeff Trawick To: Christophe JAILLET Cc: APR Developer List Content-Type: multipart/alternative; boundary=089e0115fc4ef45c1d04d94d1d79 X-Virus-Checked: Checked by ClamAV on apache.org --089e0115fc4ef45c1d04d94d1d79 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Mon, Apr 1, 2013 at 6:21 AM, Christophe JAILLET < christophe.jaillet@wanadoo.fr> wrote: > Le 28/03/2013 19:32, Jeff Trawick a =E9crit : > > On Thu, Mar 28, 2013 at 1:38 PM, Stefan Fritsch wrote: >> >>> On Monday 25 March 2013, Christophe JAILLET wrote: >>> >>>> As a first step, I noticed that apr_itoa, apr_ltoa, apr_off_t_toa >>>> could be tweaked to require less memory for some common cases. >>>> The attached patch reduces memory use for small values, that is to >>>> say for strings that fit in 8 bytes (including NULL) >>>> >>> Looks like a reasonable optimization to me. >>> >>> Cheers, >>> Stefan >>> >> When shrinking it down to 8, why not avoid the apr_palloc altogether? >> Also, how about lower-casing the name BUFFER_SIZE since it isn't >> const? >> >> >> I'm not sure it is possible to avoid the call to apr_palloc. > You're correct, of course :) > > For BUFFER_SIZE, I 100% agree with you. Previously it was a 'const int', > and I just left it as it was. > > There are also some tab vs space possible clean-up in these functions. > > Finally, even if the 3 functions work the same way, they have different > way to write it: > *--start =3D '0' + (n % 10); > *--start =3D (char)('0' + (n % 10)); > *--start =3D '0' + (char)(n % 10); > The 2nd version is, IMO, the best one. > preferred by me too > > I didn't include it in my patch to reduce the differences. > > CJ > --=20 Born in Roswell... married an alien... http://emptyhammock.com/ --089e0115fc4ef45c1d04d94d1d79 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, Apr 1, 2013 at 6:21 AM, Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
Le 28/03/2013 19:= 32, Jeff Trawick a =E9crit :

On Thu, Mar 28, 2013 at 1:38 PM, Stefan Fritsch <sf@sfritsch.de> wrote:
On Monday 25 March 2013, Christophe JAILLET wrote:
As a first step, I noticed that apr_itoa, apr_ltoa, apr_off_t_toa
could =A0be tweaked to require less memory for some common cases.
The attached patch reduces memory use for small values, that is to
say =A0for strings that fit in 8 bytes (including NULL)
Looks like a reasonable optimization to me.

Cheers,
Stefan
When shrinking it down to 8, why not avoid the apr_palloc altogether?
Also, how about lower-casing the name BUFFER_SIZE since it isn't
const?


I'm not sure it is possible to avoid the call to apr_palloc.

You're correct, of course :)
=A0

For BUFFER_SIZE, I 100% agree with you. Previously it was a 'const int&= #39;, and I just left it as it was.

There are also some tab vs space possible clean-up in these functions.

Finally, even if the 3 functions work the same way, they have different way= to write it:
=A0 =A0 *--start =3D '0' + (n % 10);
=A0 =A0 *--start =3D (char)('0' + (n % 10));
=A0 =A0 *--start =3D '0' + (char)(n % 10);
The 2nd version is, IMO, the best one.

preferred by me too
=A0

I didn't include it in my patch to reduce the differences.

CJ



-- Born in Roswell... married an alien...
http://emptyhammock.com/
--089e0115fc4ef45c1d04d94d1d79--