[Mono-list] Performance issue
Thomas F. Burdick
tfb@OCF.Berkeley.EDU
Tue, 4 Sep 2001 10:32:05 -0700
Lloyd Dupont writes:
> i recently write a graphical C# application which is also computing
> intensive. (in fact memory move)
> i had the bad surprise to see that it was a bit slower than the same
> demo in pure C.
>
> this is very annoying. Does someone know if there is performance issue
> considering C# ?
> i believe it was same performance than natively compiled code ?
>
> Has anybody experience or knowledge on his topic ?
I bet you're running into 3 issues:
1. The code is being JIT'ed
2. The MS compiler is still in beta, which I bet means they're still
adding optimizations.
3. Getting extremely efficient code out of higher-level languages
involves a certain amount of black magic and knowing one's
compiler.
As for (1), I know the Mono project intends to eventually have 2
JIT's, one for producing code quickly, and the other for producing
fast code. The first is both more generally applicable, and easier to
do, so I assume that's what MS did for their first one. It's also
really important to keep (3) in mind. In the Lisp world, I've seen
code adjusted and tweaked to get ~7.5x speed improvement on CMUCL (a
high-quality free software CL compiler), and the same adjustments made
it slow down significantly on one of the high-quality commercial
systems. So when you get down to low-level optimizations in a high
level language, it's vital that you know the precise system you're
optimizing for. FWIW, I've seen some natively compiled Lisp code run
about 20% faster than well-optimized C code compiled with gcc with
optimizations on: sometimes, expressing things in more abstract terms
can leave more optimization paths open.
So, I'd say to expect C# code in the short term to be in the ballpark
of C++, and in the long term to be anywhere from 80%-120% the speed of
C.