www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/07/06/11:20:42

Sender: root AT delorie DOT com
Message-ID: <378200AB.B0EC3DF6@inti.gov.ar>
Date: Tue, 06 Jul 1999 10:12:11 -0300
From: salvador <salvador AT inti DOT gov DOT ar>
Organization: INTI
X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.0.36 i686)
X-Accept-Language: es-AR, en, es
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
CC: eliz AT is DOT elta DOT co DOT il
Subject: Re: .align directives in libc.a
References: <199907041532 DOT LAA21196 AT indy DOT delorie DOT com>
Reply-To: djgpp-workers AT delorie DOT com

DJ Delorie wrote:

> > I'm probably missing something, because I don't understand why would
> > aligning sections to, say, 16 bytes ``waste cycles''.
>
> Imagine a ridiculous degenerate case: You have 16 one-byte functions,
> all of which are called.  If you pack them, you trigger only one
> 16-byte cache miss.  If you align them to 16-byte boundaries, you
> trigger 16 16-byte cache misses.  Padding makes your program bigger,
> so the average total number of cache misses goes up.  The trick is to
> defer those misses to places where performance isn't as critical.

One-byte functions doesn't exist so this case is not practical. A call to a
function have some cost so you want to get as much as the funtion as posible
when reading it from the cache. That's why MSVC aligns to 32 bytes. But for some
reason it also evaluates that some cases will be bad and reduces the align to 16
bytes. But that's the most agresive mode, not the common or the used by the
runtime library.

> > So perhaps we need to make the alignment of data, code and stack
> > sections be 16 bytes?
>
> We can align text to 16 and data to 8 if we want.

The main problem is the fact that we must align all the code to 16 bytes if the
user wants to align your functions to 16 bytes. That's the problem. Aligning to
16 bytes is good but will bloat libc a little bit. With some exceptions libc
functions are very slow ones (calls the OS) so there is no big gain and you
bloat the files.
Can we solve it? A solution that will work but is complex is create a special
section for slow libc functions and put there functions aligned to only 8 bytes
boundaries and align .text functions to 16 bytes boundaries putting there the
fast libc functions and user's code.

SET

--
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Visit my home page: http://welcome.to/SetSoft or
http://www.geocities.com/SiliconValley/Vista/6552/
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
                    set AT ieee DOT org set-soft AT bigfoot DOT com
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019