public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom St Denis <tstdenis@ellipticsemi.com>
To: gcc-help@gcc.gnu.org
Cc: NightStrike <nightstrike@gmail.com>,
	  "J.C. Pizarro" <jcpiza@gmail.com>,
	 Galloth <lordgalloth@gmail.com>
Subject: Re: reduce compilation times?
Date: Wed, 28 Nov 2007 12:07:00 -0000	[thread overview]
Message-ID: <474D59A4.9090701@ellipticsemi.com> (raw)
In-Reply-To: <474D2E23.6CEAA019@dessent.net>

Brian Dessent wrote:
> Tom St Denis wrote:
>
>   
>> What you really should do, is profile your code, then create "static
>> inline" or macro copies of heavily used (and not overly large) pieces of
>> code.  And even then, inlining code doesn't always help.
>>     
>
> You don't have to go to the trouble of inlining things manually, the
> compiler can do a much better job of estimating whether that's
> advantageous or not.  Just mark functions that are not for export as
> static and the compiler will now have a large range of optimizations
> that it can automatically perform, including but not limited to inlining
> them.  This is a case where having support/helper functions in the same
> .c file as the exportable functions that use them makes a great deal of
> sense.  The key word in the original statement was exportabe:
>   
Yeah, except putting all your functions in one file goes against the 
very nature of proper software development strategies.  First off, you 
should be running a profiler anyways is performance is important.  If 
you're not, then you're not very well educated in the field of work. 

That aside, the profiler will tell you where time is spent.  Yes, giving 
the compiler the option to inline or not is "ideal" but putting 100K of 
lines in a single file is not.

>> This is why you should re-factor your code as to contain only one [or as
>> few as possible] exportable functions per unit.
>>     
>
> In general the compiler can do the best job when it can see everything
> at once, which is why currently so much work is being poured into
> developing the LTO branch, which will allow the compiler do certain
> optimizations as if the entire program was a single compilation unit
> even though it was compiled separately.
>   
Often the savings, especially on desktop/server class processors from 
the minutia of optimizations possible at that level do not out weigh the 
cost to the development process. 

For example, in my math library the modexp function calls an external 
mul, sqr, and mod functions (well montgomery reduction but you get the 
point).  So even though they're not inlined (well they're big so they 
wouldn't anyways) and you have the overhead of a call, the performance 
is still 99% dominated by what happens inside the calls, not by the call 
itself.  In my case, my multipliers are fully unrolled/inlined since 
that's where the performance is to be had.  So it was worth the 
readability cost (well they're machine generated anyways) for it.

I question the sanity of a LTO step (if indeed that means it 
re-organizes the object code at link time).  It'll make debugging harder 
when supposedly non-inlined code gets inlined, or other nasties (e.g. 
picking up a constant from another module then removing dead code, etc).

I think most people would prefer their object files to be representative 
of the compiler input.

Tom

  reply	other threads:[~2007-11-28 12:05 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 16:07 J.C. Pizarro
2007-11-27 16:19 ` Brian Dessent
2007-11-27 16:26   ` J.C. Pizarro
     [not found] ` <5abcb5650711270804o171e1facr565beec70314af75@mail.gmail.com>
2007-11-27 16:41   ` J.C. Pizarro
2007-11-27 16:46     ` Tom St Denis
2007-11-27 17:16       ` J.C. Pizarro
2007-11-27 17:46         ` Tom St Denis
2007-11-27 18:26           ` Wesley Smith
2007-11-27 19:35       ` NightStrike
2007-11-27 19:41         ` John (Eljay) Love-Jensen
2007-11-27 19:49         ` Tom St Denis
2007-11-28  9:19           ` Brian Dessent
2007-11-28 12:07             ` Tom St Denis [this message]
2007-11-28 12:35               ` Brian Dessent
2007-11-27 17:44     ` Vladimir Vassilev
     [not found]       ` <998d0e4a0711271310k657b791cy6ad5cc5721105f4c@mail.gmail.com>
2007-11-27 22:30         ` J.C. Pizarro
  -- strict thread matches above, loose matches on Subject: below --
2007-11-28 16:06 J.C. Pizarro
2007-11-28 16:16 ` Tom St Denis
2007-11-28 16:34   ` J.C. Pizarro
2007-11-28 18:18     ` Tom St Denis
2007-11-28 13:56 Duft Markus
2007-11-28 14:35 ` Tom St Denis
2007-11-29  0:23 ` Tim Prince
2007-11-28 13:25 Duft Markus
2007-11-28 13:26 ` Tom St Denis
2007-11-28 12:36 Duft Markus
2007-11-28  7:57 Duft Markus
2007-11-28 12:01 ` J.C. Pizarro
2007-11-28 12:28   ` Tom St Denis
2007-11-28 12:49     ` Fabian Cenedese
2007-11-28 13:03       ` Tom St Denis
2007-11-28 12:52     ` J.C. Pizarro
2007-11-28 13:17       ` Tom St Denis
2007-11-28 13:40         ` J.C. Pizarro
2007-11-28 13:51           ` Tom St Denis
2007-11-28 13:59             ` Tom St Denis
2007-11-28 15:51             ` John (Eljay) Love-Jensen
2007-11-28 13:30       ` Ted Byers
2007-11-28 12:12 ` John (Eljay) Love-Jensen
2007-11-28 12:31   ` J.C. Pizarro
2007-11-28 12:39     ` Tom St Denis
2007-11-28 12:54     ` John (Eljay) Love-Jensen
2007-11-28 12:18 ` Tom St Denis
2007-11-28 13:09   ` Ted Byers
2007-11-27 10:04 mahmoodn
2007-11-27 11:11 ` Andrew Haley
2007-11-27 11:15   ` mahmoodn
2007-11-27 11:30     ` Andrew Haley
2007-11-27 12:20       ` mahmoodn
2007-11-27 12:25         ` John Love-Jensen
2007-11-27 15:27           ` Tim Prince
2007-11-27 14:07         ` Andrew Haley
2007-11-28  9:01           ` mahmoodn
2007-11-28 12:11             ` John (Eljay) Love-Jensen
2007-11-30  9:15               ` mahmoodn
2007-11-30 13:33                 ` mahmoodn
2007-11-27 15:48   ` Sven Eschenberg
2007-11-27 16:27     ` Andrew Haley
2007-11-27 18:51       ` Sven Eschenberg
2007-11-27 19:21         ` Andrew Haley
2007-11-27 20:43           ` Sven Eschenberg
2007-12-01 12:20   ` mahmoodn
2007-12-03 16:14     ` Andrew Haley
2007-12-04 11:23       ` mahmoodn
2007-12-04 12:19         ` Tom Browder
2007-12-05  7:44           ` mahmoodn
2007-12-05 10:24             ` Tom Browder
2007-12-05 10:29               ` mahmoodn
2007-11-27 13:48 ` John Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=474D59A4.9090701@ellipticsemi.com \
    --to=tstdenis@ellipticsemi.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jcpiza@gmail.com \
    --cc=lordgalloth@gmail.com \
    --cc=nightstrike@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).