[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jul 1 15:24:53 2003 
Subject:Re: New errno handling seems to speed up poplog 
From:Waldek Hebisch 
Volume-ID:1030701.02 

Aaron Sloman (A.Sloman@cs.bham.ac.uk) wrote:

: I wondered whether the recent changes adding extra indirection through a
: C procedure to access errno might slow down poplog.
 
: So I ran a simple benchmark (running prolog to reverse a list many
: times, generating a lot of garbage etc.).
 
: I tried this on the newly built system with the changes described in
: recent messages. I also took the old system sources and recompiled and
: relinked them. So the only differences between the two systems were in
: the small number of changed files for handling access to errno
: (two pop11 files and 1 C file).
 
: To my surprise the old version consistently took about 11 %
: longer -- using the shell 'time' command, and using the real time.
: The 'user cpu' time ratio was about the same.
 
: I.e. planting a call to a C program instead of assembling direct access
: to a C global variable in the system sources produced a significant
: speedup.
 
: I am surprised, but maybe a compiler expert would not be?
 
: It makes me wonder whether other changes would do the same.
 
: These tests were running on a 1ghz AMD athlon using redhat 8.
 
: On a 1.5ghz intel pentium 4 also running redhat 8 in the department of
: computer science the speed up was reduced to about 5%. That was on a
: machine where all files were accessed via NFS, which may have
: slightly reduced the impact of the changes because of extra time
: required for accessing remote files.
: Also the new system was not recompiled on that machine, but on the
: athlon, and then copied over to the pentium 4. I don't know if that
: would make a difference: perhaps the C compiler or the linker optimised
: for the athlon?
 
: Can anyone explain why invoking Waldek's C procedure should have
: been faster?

I think that the speedup is "random". I would be very surprised
if `errno' access was time critical. I am not able to do more 
refined test but starting poplog in the debugger shows that 
`get_libc_errno' is called 18 times before I get to Poplog prompt. 
I can see delay between hitting <enter> and getting Poplog prompt,
and I estimate that startup takes around 50 or 100 miliseconds. 
The C functions I wrote should execute in few machine clocks, so 
to get measurable influence on runtime they should be called milion
times. On the other hand adding/remowing a small piece of code
changes exact memory layout of final program. The change in layout
may easily give observed difference. Namely layaout affects:

 1) alignment (acces to unaligned data is much slower)
 2) cache hit ratio (if two memory cells have adresses differing 
    only in high order bits they compete for the same cache line)
 3) delay caused by cache misses

Except for alignment (compilers include special padding to align
data) the two other effects are almost 'random' (that is without
info about frequency of access of various memory locations there
is no way to predict which layout is better)

--
                              Waldek Hebisch
hebisch@math.uni.wroc.pl    or hebisch@hera.math.uni.wroc.pl