[cfe-dev] Question on clang design - Why clang doesn't use pooling of Process

Douglas Gregor dgregor at apple.com
Wed Jul 25 09:56:41 PDT 2012


On Jul 25, 2012, at 9:46 AM, David Blaikie <dblaikie at gmail.com> wrote:

> On Wed, Jul 25, 2012 at 4:46 AM, Journeyer J. Joh
> <oosaprogrammer at gmail.com> wrote:
>> Hello, list
>> 
>> I am reading clang source code.
>> And while my reading of it I found that clang as a driver invokes
>> another clang as a worker process to convert a input file to the
>> output file.
>> This method looks weird to me because the driver clang invokes worker
>> clang so many times. It would be the number of input source  file!
>> This means that 1000 C source code compile would invokes clang 1000 +
>> 1 times.
>> 
>> For server programming this kind of work is handled by processpool or
>> threadpool.
>> 
>> Pooling invokes process' or threads only a certain times like 10 times
>> and with this 10 process of threads tasks are handled with no more
>> loading of process load or creating new thread load.
> 
> I'm a little confused. Are you suggesting that if you run "clang a.cpp
> b.cpp -fsyntax-only" (just to ignore linking & other issues) there are
> a total of 3 processes created? The driver and then two separate
> frontend actions for a.cpp and b.cpp?

Yes, that is correct. There will be one -cc1 process per.

The real question is whether the process startup overhead is a measurable part of compilation time for a realistic source file. IIRC, we looked at this a while ago, and the answer is "no, not measurable", so it wasn't worth changing.

	- Doug




More information about the cfe-dev mailing list