You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by rb...@covalent.net on 2001/02/23 14:08:53 UTC

Re: SGI Patch 10xpatch-2.0a6-5 - eliminate use of sprintf() to format inet_ntoa conversions

On Fri, 23 Feb 2001, Bill Stoddard wrote:

> I know as fact that sprintf() is pure performance evil.  We need to eliminate
> it everywhere possible in the server. This patch remove two calls to sprintf
> for each connection.
>
> This patch needs to be reworked to fit into inet_ntop.c.  Possibly  Resubmit
> and I will review and commit it (unless someone else calls out a severe
> problem that I don;t see).

Taking a REALLY quick look at the patch and the server, this is overkill.
We only use inet_ntoa in one place in the server.  For inet_ntop, we only
use psprintf to translate integers into strings.  What we really need is a
VERY simple function that given an integer, will turn it into a string.
This should be a five or six line function, and it can be used everywhere.

Ryan


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: SGI Patch 10xpatch-2.0a6-5 - eliminate use of sprintf() to format inet_ntoa conversions

Posted by dean gaudet <dg...@arctic.org>.
On Fri, 23 Feb 2001 rbb@covalent.net wrote:

> On Fri, 23 Feb 2001, Bill Stoddard wrote:
>
> > I know as fact that sprintf() is pure performance evil.  We need to eliminate
> > it everywhere possible in the server. This patch remove two calls to sprintf
> > for each connection.
> >
> > This patch needs to be reworked to fit into inet_ntop.c.  Possibly  Resubmit
> > and I will review and commit it (unless someone else calls out a severe
> > problem that I don;t see).
>
> Taking a REALLY quick look at the patch and the server, this is overkill.
> We only use inet_ntoa in one place in the server.  For inet_ntop, we only
> use psprintf to translate integers into strings.  What we really need is a
> VERY simple function that given an integer, will turn it into a string.
> This should be a five or six line function, and it can be used everywhere.

there are faster ways to convert an 8-bit integer to a base-10
representation than there are to convert 32-bit integers to base-10.
part of the point of the patch is to take advantage of this fact...
if you can actually convince the compiler to generate an 8-bit division
it'll generally complete faster than the full 32-bit division.

the only way to be sure your general approach is the right one is to
actually benchmark multiple methods.

-dean