[cfe-dev] In-process compiler driver

Vedant Kumar via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 28 17:02:26 PDT 2016


> in-process and without forking multiple processes

First off: if your goal is to speed up your builds, I don't think eliminating
fork() overhead is a promising place to start.  In the measurements I've done,
the time spent in fork() during a build of `llvm-as' is a tiny, tiny fraction
of one percent.

You can measure this overhead for yourself using dtruss/strace. I suspect that
it's so low because modern OS's use copy-on-write to set up address spaces for
child processes.

> compile from source to final executable without fork

If fork() performance overhead is really a problem, or you'd prefer a
non-forking design, I can think of two options.

You could turn the tools in your toolchain into long-lived servers, or you
could (as you mentioned) call into a tool library instead of calling
ExecuteAndWait.

One *advantage* of a fork-based pipeline is that tools never need to clean up
after themselves. E.g, when we fork off a `clang -cc1' instance, we pass it
`-disable-free'. This is a significant time savings (2-3% on average while
building llvm tools). This same performance advantage is available to the
linker, dsymutil, etc.

best,
vedant


> On Jul 28, 2016, at 3:23 AM, Nikolay Haustov via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Currently, Clang Driver library is designed around Actions/Tools which are assumed to be external tools and invoked with ExecuteAndWait.
> 
> Is there a way to get benefits of driver library integration, but in-process and without forking multiple processes? In other words, compile from source to final executable without fork? If no, how hard would it be to change driver library to make possible to do that?
> 
> Thanks
> Nikolay
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list