httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@leland.Stanford.EDU>
Subject Re: [Fwd: Problem 2534]
Date Tue, 04 Aug 1998 00:12:12 GMT
On Mon, 3 Aug 1998, Dean Gaudet wrote:

> > I mean, heck, it would save a whole 77 bytes of memory per process!
> 
> I don't understand how you're coming to this conclusion either:
> 
>     char foo[] = "hello";
> 
> consumes 6 bytes of memory;
> 
>     char *foo = "hello";
> 
> consumes 10 bytes of memory (on a 32-bit box).

Yes. But let's presume we're on some system (that may not exist), that has
shared code segments, but not copy-on-write data segments. Let's further
presume that the compiler puts the string literals in the code segment,
and makes them unwritable (which it's allowed to do). So with the array
version, each process (recall that Apache is multi-process *grin*) has a
copy of the 113 bytes neccessary to store the nine end_* strings. Wheras
with the pointer version, they each only need 36 (4*9) bytes, and can
point to the shared version of the strings. 113-36 = 77 bytes saved.

It was a silly comment.

> Furthermore, the first example allows the compiler to generate constants
> inline (with attached relocations).  This favours boxes like the x86 which
> allow 32-bit constants in the instruction stream.  The second example
> requires the compiler to load memory first.  There's little difference
> between the two on RISC processors. 

Point.

> Yeah yeah, it's me being picky about optimization, but hell, it's not like
> I went in there with the express purpose of making it faster.  I went in
> there to fix a bug, and in the process made the code more efficient.  I
> don't understand why we're arguing about a bug in one version of the
> compiler on AIX -- just turn off optimization.  We didn't bend over
> backwards to suit SCO's broken compilers -- we just told people to turn
> off optimization. 

I think AIX is broken regardless, and pointers vs. arrays don't fix it. I
think right now we're just arguing about C in general, just for its own
sake ;)

(would you expect anything more from the Apache Group?)

-- Alexei Kosut <akosut@stanford.edu> <http://www.stanford.edu/~akosut/>
   Stanford University, Class of 2001 * Apache <http://www.apache.org> *



Mime
View raw message