[Simh] Simh execution speed improvement - about 45% improvement.
Davis Johnson
davis at frizzen.com
Wed Jan 23 20:12:23 EST 2008
Jan-Benedict Glaw wrote:
>On Tue, 2008-01-22 20:21:00 -0500, Davis Johnson <davis at frizzen.com> wrote:
>
>
>>improvement from inlining alone. Function call overhead is relatively
>>small, after all. I did expect it to be at least measurable. I expected
>>
>>
>
>Calling a function is quite some thing! I wouldn't call it `small'
>after all! RAM accessing is one of the most used operations and as a
>hot path, every single CPU instruction used to access it really counts
>a lot...
>
>MfG, JBG
>
>
>
Function call overhead is relatively small.
I ran my numbers on an ultra-SPARC system where there is generally no
need to save any registers, or restore them on exit. The call itself is
little more expensive than a regular branch. The return is just another
branch. Parameters are generally passed in registers, so setup before
the call is making sure the right values are in the right registers. A
similar situation exists on other RISC architectures (PPC, Alpha -- less
so for MIPS).
While every cycle does count, the few used by the call itself is small
compared to the body of all but the smallest functions. A simulated
memory access in SIMH typically needs to worry about one or more of
memory relocation, protection (read, write, execute protect), access
levels, possible page faults, dirty bits, byte order issues, and
possibly other minutia.
I'd say that the function call overhead is _relatively_ small. Probably
even on Intel CPUs.
Inlining the functions is still a powerful idea, just not because of
eliminated function call overhead. It is powerful because it allows the
optimizer to apply information from the context of the call to the
optimization of the function body. The function body gets optimized in
the same register allocation context as the caller. Common sub
expressions can be found that exist in both called and caller. If tests
and branches can frequently be eliminated. And so on and so on. Almost
every optimization trick works better.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.trailing-edge.com/pipermail/simh/attachments/20080123/0350a9f7/attachment-0003.html>
More information about the Simh
mailing list