public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Precompiled headers (or other speed ups)
@ 2001-01-10 11:45 dewar
  0 siblings, 0 replies; 30+ messages in thread
From: dewar @ 2001-01-10 11:45 UTC (permalink / raw)
  To: dkorn, zackw; +Cc: dewar, gcc

<<I don't know enough about C++ or its implementation in GCC to say for
sure what the ultimate cause is.  I've been told that C++ has an
extremely ambiguous grammar and the parser has to accumulate entire
statements on the stack before it can begin to match anything.
There's an ad-hoc layer in between the lexer and the parser
(cp/spew.c) whose purpose is to rearrange the order in which certain
constructs appear so they are easier to parse; you can imagine the
mess that would require that.
>>

Sounds to me like the new Code Sourcery project to redo the parser has
the potential for good gains here. 

^ permalink raw reply	[flat|nested] 30+ messages in thread
* RE: Precompiled headers (or other speed ups)
@ 2001-01-10 10:21 dewar
  0 siblings, 0 replies; 30+ messages in thread
From: dewar @ 2001-01-10 10:21 UTC (permalink / raw)
  To: dewar, dkorn; +Cc: gcc

Well I guess neither of us knows enough to contribute further, but I
remain susprised that the issue should be front end speed rather than
backend speed.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* RE: Precompiled headers (or other speed ups)
@ 2001-01-10  9:56 David Korn
  2001-01-10 11:14 ` Zack Weinberg
  0 siblings, 1 reply; 30+ messages in thread
From: David Korn @ 2001-01-10  9:56 UTC (permalink / raw)
  To: 'dewar@gnat.com'; +Cc: gcc

><<  Well, only really surprising if you assume the parsing code is well
>written :-) After all, the mid/backend is mostly doing memory-memory
>transforms on the trees, and that's going to run as fast as your cache
>and cpu can handle.  Parsers, OTOH, have to I/O.  Badly written parsers
>might even use c stdio functions to fgetc the entire file one char at a
>time....
>>>
>
>Sure, but that presumably is an easy thing to fix. In GNAT, the entire
>file is read with a single read, and then all access to the file is to
>the in memory copy, which stays around throughout the compilation.

  Oh yeah; I was just suggesting it wouldn't be *surprising*, not that it
would be 'right'!  Last time I looked at bison (or was it lex or yacc? I
forget) was around '95 and it did tend to turn out fairly sucky code (in
terms of f-stdio) if you didn't know what you were doing and how to hook
it into a memory buffer.  I haven't looked at the gcc parsers yet but I
would hope that they don't have such obvious design flaws.....

  Another thing that could eat time in a parser would be if there were
numerous shift-reduce conflicts that caused a lot of backtracking on fairly
common constructs.  That's just a for-example also :)

    DaveK

-- 
The Boulder Pledge: "Under no circumstances will I ever purchase anything 
offered to me as the result of an unsolicited email message. Nor will I 
forward chain letters, petitions, mass mailings, or virus warnings to large 
numbers of others. This is my contribution to the survival of the online
community." 


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-10  9:35 dewar
  2001-01-10 18:53 ` Yu Xuanwei
  0 siblings, 1 reply; 30+ messages in thread
From: dewar @ 2001-01-10  9:35 UTC (permalink / raw)
  To: gcc, pedwards

<<Perhaps in Ada parsing only takes microseconds.  In most of the C-family
languages with which I am familiar, parsing takes the majority of the time.
>>

If by parsing you mean lexical analysis and construction of the syntax
tree (NOT including static semantic analysis), then this should be very
rapid. There is nothing especially difficult about C or C++ with respect
to lexical analysis and parsing.

If the static semantic analysis is taking a lot of time, perhaps there
are some non-optimal algorithms that need looking at. I do not see why
C++ should be significantly harder to handle than Ada 95 in this regard.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* RE: Precompiled headers (or other speed ups)
@ 2001-01-10  9:29 dewar
  0 siblings, 0 replies; 30+ messages in thread
From: dewar @ 2001-01-10  9:29 UTC (permalink / raw)
  To: dewar, dkorn; +Cc: gcc

<<  Well, only really surprising if you assume the parsing code is well
written :-) After all, the mid/backend is mostly doing memory-memory
transforms on the trees, and that's going to run as fast as your cache
and cpu can handle.  Parsers, OTOH, have to I/O.  Badly written parsers
might even use c stdio functions to fgetc the entire file one char at a
time....
>>

Sure, but that presumably is an easy thing to fix. In GNAT, the entire
file is read with a single read, and then all access to the file is to
the in memory copy, which stays around throughout the compilation.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* RE: Precompiled headers (or other speed ups)
@ 2001-01-10  9:11 David Korn
  0 siblings, 0 replies; 30+ messages in thread
From: David Korn @ 2001-01-10  9:11 UTC (permalink / raw)
  To: 'dewar@gnat.com'; +Cc: gcc

>-----Original Message-----
>From: dewar@gnat.com [ mailto:dewar@gnat.com ]

><<was posted in last August, but there is a good example of how the parser
>can dominate just about everything.  That message kicked off a very good
>discussion on precompiled headers and parsing performance in C++.
>>.
>
>This is quite surprising, depending on what parsing means, if parsing
>means just building a syntax tree from the grammar, it is amazing that
>this should take any time at all compared to other phases.

  Well, only really surprising if you assume the parsing code is well
written :-) After all, the mid/backend is mostly doing memory-memory
transforms on the trees, and that's going to run as fast as your cache
and cpu can handle.  Parsers, OTOH, have to I/O.  Badly written parsers 
might even use c stdio functions to fgetc the entire file one char at a 
time....

    cheers, 
       DaveK
-- 
The Boulder Pledge: "Under no circumstances will I ever purchase anything 
offered to me as the result of an unsolicited email message. Nor will I 
forward chain letters, petitions, mass mailings, or virus warnings to large 
numbers of others. This is my contribution to the survival of the online
community."


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-10  9:02 Phil Edwards
  0 siblings, 0 replies; 30+ messages in thread
From: Phil Edwards @ 2001-01-10  9:02 UTC (permalink / raw)
  To: gcc

> This is quite surprising, depending on what parsing means, if parsing
> means just building a syntax tree from the grammar, it is amazing that
> this should take any time at all compared to other phases.

Perhaps in Ada parsing only takes microseconds.  In most of the C-family
languages with which I am familiar, parsing takes the majority of the time.

My only point here is that precompiled headers /do/ make a difference and
/will/ be a very big win once they are implemented, especially for C++.
The current 10x-20x lossage on PPC is painful to hear about, and I don't
even use that platform.  :-)


Phil

-- 
pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-10  8:50 dewar
  0 siblings, 0 replies; 30+ messages in thread
From: dewar @ 2001-01-10  8:50 UTC (permalink / raw)
  To: ak, pedwards; +Cc: dewar, gcc, shebs

<<was posted in last August, but there is a good example of how the parser
can dominate just about everything.  That message kicked off a very good
discussion on precompiled headers and parsing performance in C++.
>.

This is quite surprising, depending on what parsing means, if parsing
means just building a syntax tree from the grammar, it is amazing that
this should take any time at all compared to other phases.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-09 19:52 dewar
  0 siblings, 0 replies; 30+ messages in thread
From: dewar @ 2001-01-09 19:52 UTC (permalink / raw)
  To: dewar, shebs; +Cc: amep, gcc

<<> By comparison, if you use GNAT to compile the DEC starlet library, which
> is 64,000 lines of very dense declarations, that is with'ed by typical
> applications, much as a C++ compiler eats headers with #include, it takes
> a few seconds on a fast PC.

Watch out for those "few seconds"! - if you're compiling 360 source
files, 10 seconds/compile adds up to a full hour.  To be as fast as MW,
you have to get done with each file in under a second.
>>

r
few seconds actually is about 2.3 seconds ....


my point here is that there is a big discprepancy between the speeds, and
that is strange. As I say, our impression for the GNAT case is that we
would not save much by the equivalent of precompiling headers ...

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-09 14:55 dewar
  2001-01-09 15:43 ` Stan Shebs
  2001-01-10  5:29 ` Andi Kleen
  0 siblings, 2 replies; 30+ messages in thread
From: dewar @ 2001-01-09 14:55 UTC (permalink / raw)
  To: dewar, shebs; +Cc: amep, gcc

<<They would just make MW builds go faster too, so GCC still looks
just as lame.
>>

Well I am not so sure about that. Early on, Realia COBOL compiled 10,000
lines/minute on a 4.77MHz PC1. The major competitor was about ten times
slower. That made a real difference.

But after a while, by the time we moved to 25MHz 386's, the difference
was 100,000 lines/minute vs 10,000 lines/minute, and that was not so
critical in practice.

These days, it is probably 1 million lines/minute vs 100,000 lines/minute
or something like that and it does not matter at all.

So absolute speeds are important.

Of course the speeds that Stan is reporting are horribly slow in absolute
terms. The real question is *why* slo slow. 150K lines of decls
to be crunched should not be taking anywhere NEAR that long, since it
is not necessary to generate full code for these decls, or at least 
should not be.

By comparison, if you use GNAT to compile the DEC starlet library, which
is 64,000 lines of very dense declarations, that is with'ed by typical
applications, much as a C++ compiler eats headers with #include, it takes
a few seconds on a fast PC. 

That's too big of a difference in performance to be easily explainable.

In the case of GNAT, we are not at all convinced that the equivalent of
compiled headers would be a win, since the intermediate compiled output
of something like starlet is pretty big (the compressed tree is 10 megs
compared to the source size of 2.2 megs, so you have a lot more I/O).

When I said that I did not consider fast compilation to be a major goal
of gcc, I was talking about the back end and code generator, but if I
understand things clearly, it is the C++ *front end* that is eating up
time here, and that seems surprising.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-09 11:26 dewar
  0 siblings, 0 replies; 30+ messages in thread
From: dewar @ 2001-01-09 11:26 UTC (permalink / raw)
  To: amep, gcc; +Cc: dewar

<<I'm sorry if my message came across as a complaint. It was only meant
as an inquiry to see if there was something I could play with and test
for people. I know my machine is "archaic", but I'm a pour 16-year
old. ;) I can't a afford even a $1000 dollar machine (and that
wouldn't be a particularly great machine). Anyway, sorry if I
offended. :-)
>>

I don't think you offended anyone!

The real issue is how much effort to spend on compilation time issues,
and also whether this particular case is anomolous or not.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-08 21:09 dewar
  2001-01-09  0:33 ` Geoff Keating
  0 siblings, 1 reply; 30+ messages in thread
From: dewar @ 2001-01-08 21:09 UTC (permalink / raw)
  To: amep, geoffk; +Cc: gcc

<<Yes, I'm actively working on precompiled headers.  They've been
delayed a bit to allow for the GCC 3.0 release to get out the door,
but they should be in 3.1.
>>

It's always interesting to know whether this will be a significant 
speed up, or not. Do you have data yet?

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Precompiled headers (or other speed ups)
@ 2001-01-08 20:41 dewar
  2001-01-09  3:01 ` Rob Taylor
                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: dewar @ 2001-01-08 20:41 UTC (permalink / raw)
  To: amep, gcc

<<<Skip this paragraph if your not interested in the details of my
situation.> I have a single source file that takes 5-7 min to compile
on my Pentium 133 64M RAM. The file uses the following libraries:
GTK--, MySQL++ and STL. Pre-processed the file is 1.2M and it
contains 423 classes. That's really big I know, but there ought to be
some way to at least bring down the compile time a bit.
>>

But why use such a slow obsolete machine for such a large project? That
seems a real mismatch to me. What would be interesting is to see how
fast your program compiles on a modern inexpensive machine (for under
$2K, you can get a gigahertz Athlon machine with 256 meg of memory).

Now, of course it is nice if things compile fast on your relatively slow
machine, and from a conceptual point of view, there is no reason why this
should not be the case (Realia COBOL would compile probably close to 
half a million lines a minute on your machine, and COBOL is quite a
complex language!). 

However, super fast compilation speed has never been a gcc goal. Early on
this was problematic, but our experience, at least in the GNAT world, is
that machines are getting fast enough that compilation time is not a
bottleneck for most folks, even though gcc may have got slower in absolute
terms.

Of course it is always worth smoking out bottlenecks, but I find the
compilation performance you report not unreasonable. Why on EARTH do
you have a single source file this long -- sounds like simply awful
programming style???

^ permalink raw reply	[flat|nested] 30+ messages in thread
[parent not found: <978997896.4164.ezmlm@gcc.gnu.org>]

end of thread, other threads:[~2001-01-10 22:55 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-10 11:45 Precompiled headers (or other speed ups) dewar
  -- strict thread matches above, loose matches on Subject: below --
2001-01-10 10:21 dewar
2001-01-10  9:56 David Korn
2001-01-10 11:14 ` Zack Weinberg
2001-01-10 13:54   ` Neil Booth
2001-01-10 15:45     ` Zack Weinberg
2001-01-10 15:26   ` Joe Buck
2001-01-10  9:35 dewar
2001-01-10 18:53 ` Yu Xuanwei
2001-01-10  9:29 dewar
2001-01-10  9:11 David Korn
2001-01-10  9:02 Phil Edwards
2001-01-10  8:50 dewar
2001-01-09 19:52 dewar
2001-01-09 14:55 dewar
2001-01-09 15:43 ` Stan Shebs
2001-01-10 22:55   ` Toon Moene
2001-01-10  5:29 ` Andi Kleen
2001-01-10  8:32   ` Phil Edwards
2001-01-10 15:12   ` Stan Shebs
2001-01-09 11:26 dewar
2001-01-08 21:09 dewar
2001-01-09  0:33 ` Geoff Keating
2001-01-08 20:41 dewar
2001-01-09  3:01 ` Rob Taylor
2001-01-09 10:04 ` amep
2001-01-09 14:36 ` Stan Shebs
     [not found] <978997896.4164.ezmlm@gcc.gnu.org>
2001-01-08 19:45 ` amep
2001-01-08 21:00   ` Geoff Keating
2001-01-09  0:41     ` Adrien Hernot

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).