Bug 24208 - C++ front-end can still be sped up
Summary: C++ front-end can still be sped up
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: compile-time-hog
: 58575 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-05 00:02 UTC by Chris Lattner
Modified: 2023-02-06 10:55 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-08 05:22:01


Attachments
Large C++ file (162.08 KB, application/x-gzip)
2005-10-05 00:03 UTC, Chris Lattner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2005-10-05 00:02:30 UTC
Here's a case where the C++ front-end is still slow, despite the great improvements in GCC 4.  This is preprocessed with Apple's 4.x compiler.

From, 'g++ IC.ii -ftime-report -O0 -o /dev/null -S', I get:

 parser                :   1.84 (27%) usr   1.48 (29%) sys   3.22 (27%) wall
 name lookup           :   1.47 (22%) usr   2.59 (51%) sys   4.06 (34%) wall
...
 TOTAL                 :   6.73             5.04            11.88

On a somewhat scary note, compiling without -ftime-report speeds up the compilation from 0:11.95 to 0:04.39.  This leads me to believe that the -ftime-report numbers can't be trusted very much.

More testcases are always good right?

-Chris
Comment 1 Chris Lattner 2005-10-05 00:03:17 UTC
Created attachment 9886 [details]
Large C++ file
Comment 2 Andrew Pinski 2005-10-05 00:08:41 UTC
(In reply to comment #0)
> On a somewhat scary note, compiling without -ftime-report speeds up the
> compilation from 0:11.95 to 0:04.39.  This leads me to believe that the
> -ftime-report numbers can't be trusted very much.

This is because Darwin's timing functions are slow.
Comment 3 Andrew Pinski 2005-10-09 18:39:50 UTC
Confirmed.  The middle-end problems are almost all in reload.c.

For the profile, everything is just spread all around.
Comment 4 Andrew Pinski 2005-10-09 18:48:55 UTC
I think this is just a problem of templates, lots of them.
Comment 5 Chris Lattner 2005-10-09 22:02:41 UTC
Some updates: the -ftime-report problems were a local problem with apple's gcc, now fixed.  This testcase has some templates (e.g. the match stuff), but mostly it is just big branchy compiler code :), not atypical of many C++ programs.

-Chris
Comment 6 Andrew Pinski 2006-11-15 04:46:27 UTC
In 4.2.0 on i686-linux-gnu this is much better:
 parser                :   1.99 (31%) usr   0.28 (28%) sys   2.42 (25%) wall   43674 kB (49%) ggc
 name lookup           :   0.48 ( 7%) usr   0.37 (37%) sys   1.51 (16%) wall    5041 kB ( 6%) ggc
Comment 7 Andrew Pinski 2006-11-15 04:48:30 UTC
Note, I am not going to close this bug just yet because this testcase produces some weird -O2 timing results for 4.2.0:
 tree operand scan     :  11.29 (27%) usr   0.51 (22%) sys  13.09 (25%) wall    9015 kB ( 4%) ggc
Comment 8 Paolo Carlini 2013-10-02 08:31:09 UTC
*** Bug 58575 has been marked as a duplicate of this bug. ***
Comment 9 Patrick Palka 2016-01-28 01:07:01 UTC
Author: ppalka
Date: Thu Jan 28 01:06:29 2016
New Revision: 232912

URL: https://gcc.gnu.org/viewcvs?rev=232912&root=gcc&view=rev
Log:
Low-hanging C++-lexer speedup (PR c++/24208)

gcc/cp/ChangeLog:

	PR c++/24208
	* parser.c (LEXER_DEBUGGING_ENABLED_P): New macro.
	(cp_lexer_debugging_p): Use it.
	(cp_lexer_start_debugging): Likewise.
	(cp_lexer_stop_debugging): Likewise.


Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
Comment 10 Richard Biener 2023-02-06 10:55:31 UTC
The testcase no longer works, even after unincluding.  There have been improvements to the operand scanner, so let's close it as fixed.