Issue Details (XML | Word | Printable)

Key: PCC-37
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Anders Magnusson
Reporter: Andrew Doran
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

cpp is slow

Created: 19/Feb/09 02:50 PM   Updated: 01/Aug/09 05:59 PM
Component/s: C preprocessor
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. Text File gprof.txt (62 kB)

Environment: Tested on NetBSD ~5, Ubuntu 8.10


 Description  « Hide
I'm reporting this because I haven't seen it noted elsewhere and think
it would be good to have a record of it.

I ran a simple test, 10000 x #include <sys/types.h>, preprocess only:

pcc 21.08s real 20.73s user 0.25s system
bsd 1.93s real 1.71s user 0.20s system
gcc 0.05s real 0.03s user 0.02s system

bsd is the preprocessor from MirOS src/libexec/cpp, apparently from 4.4BSD.

Looking at gcc/pcc with ktrace/truss, gcc does not seem to be
doing anything particularly special. It appears to be re-parsing
the files, but I haven't looked at its source. So it's I/O pattern looks
much like pcc.

I don't think it is related to I/O methods, memory allocation or nults-and-bolt
stuff like symbol lookup. It seems to be the lex/yacc parser.

It's unfortunate because the preprocessor is eating up a lot of the
efficiency that the compiler itself displays.

I have attached gprof output. It's from a short 20 second run but
does give some indication of what goes on.

I don't have time to look at this in depth (I wish I did).


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 19/Feb/09 04:21 PM
It's well-known that it is slow, the lex usage is just a quick hack and I have planned a long time to fix the tokenizer.
I think it is possible to do a really efficient keyword matcher for cpp and just replace it, but haven't done that yet.

Anders Magnusson added a comment - 19/Feb/09 08:40 PM
A ktrace of gnu cpp shows that it only reads in the files once, then it reparses them. So, much less I/O. But as you wrote, there's other things that takes time.

Andrew Doran added a comment - 19/Feb/09 11:27 PM
Ok, I must have misinterpreted the ktrace output I was looking it.
Or you could be looking at a different version. Anyway that
would certainly explain the very low system time with gcc/cpp.

Anders Magnusson added a comment - 01/Aug/09 05:59 PM
So, now the preprocessor should be much nearer "line speed".