CSharp parser performance

Jakob Petsovits jpetso at gmx.at
Sun Aug 6 00:38:27 UTC 2006


On Saturday, 5. August 2006 21:38, Adam Treat wrote:
> Hi all,
>
> I was testing the C# parser and found that I can parse every file in Mono's
> corelib (minus the tests) and start the KDevelop 4 project in less than 5
> seconds.

You mean mono-[version]/mono/* ?
That's just 325 .cs files (including the tests dir), so it's no big surprise 
that the parser doesn't need much time there.
Here are my benchmarks - three runs (Pentium-M 1.6 GHz laptop, slow hd):

csharp/external-reps/mono-1.1.16.1/mono$ find -name "*.cs" | wc -l
325

external-reps/mono-1.1.16.1/mono$
time find -name "*.cs" -exec ../../../csharp-parser {} \; -print >& /dev/null

real    0m1.270s
user    0m0.836s
sys     0m0.368s

csharp/external-reps/mono-1.1.16.1/mono$ cd ..

csharp/external-reps/mono-1.1.16.1$ find -name "*.cs" | wc -l
10831

csharp/external-reps/mono-1.1.16.1$
time find -name "*.cs" -exec ../../csharp-parser {} \; -print >& /dev/null

real    1m42.066s
user    0m55.879s
sys     0m13.889s

csharp/external-reps/mono-1.1.16.1$ cd ..

csharp/external-reps$ find -name "*.cs" | wc -l
17050

csharp/external-reps$
time find -name "*.cs" -exec ../csharp-parser {} \; -print >& /dev/null

real    2m39.620s
user    1m21.281s
sys     0m20.449s

Thanks to Roberto for the shell magic :)


> I've also determined that the C# parser suffers multi-threading problems.
> When I run more than one parse at a time in multiple threads, I get
> crashes. This probably has to do with the static variables.  Especially the
>
> char *_G_contents;
>
> variable.

I'll move that one away, but it's not the problem here (rather a symptom).
The real problem is Flex, which is storing its state between subsequent calls 
of yylex(). So this is maybe the right time for me to try out Flex'
"experimental" C++ class mode.

Hopefully that'll do away with multithreading problems.

> Jakob, I'm also going to work on the kdevelop-pg serialization of AST's.

Won't hold you back!
When you need something from me, well, you know how to find me.

Your favorite parser guy,
  Jakob




More information about the KDevelop-devel mailing list