Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/sys



Dave Sainty writes:

> "Steven J. Dovich" writes:
> 
> > Hubert Feyrer wrote:
> > > On Sun, 4 Jan 2004, Matthias Scheler wrote:
> > > > Because it is broken by design if a header file doesn't include header
> > > > files it requires itself. And because this is a regression. The 
> > > > application
> > > 
> > > I'm with Matthias on this issue - IMHO every header should pull in all the
> > > things it needs.
> > 
> > And that coddles the lazy at the expense of compile time. Consider
> > the lexing costs for all the redundant including of required headers
> > which have already been included. That can amount to a measurable
> > difference in compile time, particularly when extended across the
> > entire NetBSD source tree.
> 
> From the GNU cpp(1) info node:  "Once-Only Include Files"

Or to prove the point :)

for i in `cd /usr/include; echo sys/*.h`; do echo "#include <$i>"; done >| x; 
/usr/bin/time sh -c "cpp x >/dev/null 2>&1"
        0.15 real         0.06 user         0.01 sys

ls -1S /usr/include/sys|head -1
syscallargs.h

echo "#include <sys/syscallargs.h>">|x; /usr/bin/time sh -c "cpp x >/dev/null 
2>&1"
        0.02 real         0.00 user         0.00 sys

for i in {1..1000}; do echo "#include <sys/syscallargs.h>"; done >| x; 
/usr/bin/time sh -c "cpp x >/dev/null 2>&1"
        0.02 real         0.01 user         0.00 sys

.... including the same required header once or 1000 times incurs
negligible overhead (with our cpp).  Including unnecessary headers for
convenience will, as always, incur an overhead.

... but if it's required, then it's required.

Cheers,

Dave



Home | Main Index | Thread Index | Old Index