From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Martin v. Loewis" To: arysin@yahoo.com Cc: gcc@gcc.gnu.org Subject: Re: GCC speed Date: Fri, 31 Dec 1999 23:54:00 -0000 Message-ID: <199912231015.LAA00894@loewis.home.cs.tu-berlin.de> References: <19991223011456.2597.qmail@web107.yahoomail.com> X-SW-Source: 1999-12n/msg00505.html Message-ID: <19991231235400.MLGFPEJtwiVvPzmz9a9s84E5IkZH7T_HBBgNrVP9dSU@z> > Would you please tell me what is the bottleneck of G++ > for today? AFAIK, there are two major consumers of compile time in g++ today: overload resolution, and template instantiation. When you have lots of functions with the same name, g++ will need some time for each call, in overload resolution. This is what makes a C compiler faster: You don't have overload resolution in C. Things get more tricky due to conversion sequences, which all have to be computed. For templates, every instantiation is time-consuming, as it involves creating a deep copy of the template. This nicely combines with overload resolution: If lookup finds a template function, the following things must happen: - deduction of template arguments from the function call arguments - instantiation of the selected template - computation of conversion sequences for the instantiated parameters - participation of the instance in overload resolution. Please note that the standard library defines a number of template functions on its own, so you might see more templates than you are aware of. Template operators are particularly bad, since you need to look at them every time an operator is used. For example, for strings, there is an operator template inline bool operator>= (const basic_string & lhs, const basic_string & rhs) { return (lhs.compare (rhs) >= 0); } This is considered every time you have >= in your program, and so on. You may want to check out the development snapshot of gcc and see how it works, it should have a number of improvements in the area of compilation speed; although nobody has analysed this in detail, so far. Hope this helps, Martin