discuss-gnustep
[Top][All Lists]
Advanced

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

Re: objective-c: how slow ?


From: Malmberg
Subject: Re: objective-c: how slow ?
Date: Sat, 01 Sep 2001 01:05:50 +0200

> Hi,
> 
> I was just wondering what was the impact of messaging on the speed of an
> objective-c program. I've read somewhere about the @SEL directive (I'm
> not sure about the name), which allows for optimizing often invoked
> methods. But is there a possibility that the compiler does such
> optimization right away ? Is the @SEL "trick" an absolute requisite when
> optimizing programs ?

I thought about hacking gcc to try to do something like this, but if I
understand things correctly, you can't since the function for the
selector might change if the called function eg. dynamically loads a new
category.

> Does someone know about potential benchmarking results ? Has someone
> already tested the performance differences between programs written in
> C, Objective-C, C++ and Java ?

I did some hacking on gcc (2.95.2) a while back to try to make the
message passing code more efficient and did some benchmarking. For the
common case of a local, valid selector, calling an empty method took ~45
cycles on a PII. After trying to make the generated code in the caller
smaller and rewriting objc_msg_lookup* in assembly by hand (tried to
optimize the common path through it), and making some other changes, I
got it down to ~22 cycles. I could probably gain some more speed by
sacrificing the smaller code, and possibly some more by more careful
assembly.

Anyway, gnustep base and gui compiled and worked fine with the new
gcc/libobjc (well, not on the first try, but eventually). Once I get
around to installing gcc 3.0, I'll probably try to move the changes
over. If anyone's interested I could upload patches to 2.95.2 somewhere,
or (given some time) change it to use the old call style and the new
objc_msg_lookup, which is what I think would give the best performance.

- Alexander Malmberg




reply via email to

[Prev in Thread] Current Thread [Next in Thread]