* times(2) no sys_call ??
@ 1996-05-09 17:08 Harald Koenig
0 siblings, 0 replies; 7+ messages in thread
From: Harald Koenig @ 1996-05-09 17:08 UTC (permalink / raw)
Hi,
why is times(2) no real system call as `man times' implies ?
for alpha this is implemented in libc using 3 syscalls
getrusage(RUSAGE_SELF, {...})
getrusage(RUSAGE_CHILDREN, {...})
gettimeofday({...}, NULL)
and it is not values in terms of clock ticks (which would be 1024/sec
for Linux/AXP) but are scaled to "CLK_TCK"s which are defined as 100
in <time.h>.
for x86-Linux times() really is a system call and thus really returning
clock tickes.
for DEC Unix times() again is implemeted using getrusage/gettimeofday
(thanks to Linux strace ;-) but here CLK_TCK is 60 :-(
I slipped into this when I tried to figure out why I get different
CPU time results for my "benchmark" fortran application which I compiled
with both gcc and DEC-cc using the same f2c-converted C sources.
this is part of the reason that I reportedsome days before that
gcc compiled f2c-converted code takes twice as much cpu time as
the same DEC-cc compiled binary because I relied on the timing
output of the program itself which uses times(2). I've checked the
correct cpu time output first with "time program ..." for the gcc version
and forgot to do the same for the DEC unix binary (partly because I didn't
have the idea that a "system call" can return different values for
differenct compiler/libc combinations (when returning reasonable values
which shows that the syscall succeeded...). so the cpu ratio between
the gcc and cc compiled programs are only 1.2.
for completeness here are the CPU times for this program for
gcc and cc (using f2c), DEC f77 and f90, always using "-O2":
gcc_ratio
gcc 1548.95user 8.06system 25:57.20elapsed 99%CPU 1.00
cc 1318.54user 6.93system 22:07.94elapsed 99%CPU 1.17
f77 1030.31user 2.09system 17:14.05elapsed 99%CPU 1.50
f90 1113.64user 2.24system 18:37.76elapsed 99%CPU 1.39
but no reason to be too happy about the optimisation of gcc (since 17% less
wouldn't be that bad for a weird f2c-converted strange fp based C program
only using REAL*4 aka float):
yesterday I run a "virtex" binary from a DEC Unix machine on Linux
(this one used shared libs; after borrowing /sbin/loader and /usr/shlib/libc.so
for this test the binary run fine) and compared it with the Red Hat binary
TeXing texbook.tex which is 494 pages plain TeX). this time
I used /usr/bin/time to get the CPU time and got
GCC binary : 37 seconds
DEC-cc & shared : 22 seconds
which is almost a ratio of 1.7 :-(
tomorrow hopefully I'll get a "stage 1" gcc compiler which has been built
with DEC cc. I'm really curious how much difference in compilation
CPU time this will give...
Harald
--
All SCSI disks will from now on ___ _____
be required to send an email notice 0--,| /OOOOOOO\
24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
Harald Koenig, \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik // / \\ \
koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: times(2) no sys_call ??
@ 1996-05-10 4:42 David Mosberger-Tang
1996-05-10 7:53 ` Harald Koenig
1996-05-10 7:53 ` Harald Koenig
0 siblings, 2 replies; 7+ messages in thread
From: David Mosberger-Tang @ 1996-05-10 4:42 UTC (permalink / raw)
>>>>> On Thu, 9 May 1996 19:08:34 +0200 (MET DST), koenig@tat.physik.uni-tuebingen.de (Harald Koenig) said:
Harald> for DEC Unix times() again is implemeted using
Harald> getrusage/gettimeofday (thanks to Linux strace ;-) but here
Harald> CLK_TCK is 60 :-(
This seems the "standard" value. It's the same value that glibc uses.
I don't think there is anything in POSIX requires CLK_TCK to equal HZ.
And since OSF/1 uses 60 as well, it's probably better to stick with
that value.
IMHO: avoid times() if you can...
--david
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: times(2) no sys_call ??
@ 1996-05-10 5:07 David Mosberger-Tang
1996-05-17 9:11 ` Harald Koenig
0 siblings, 1 reply; 7+ messages in thread
From: David Mosberger-Tang @ 1996-05-10 5:07 UTC (permalink / raw)
>>>>> On Thu, 9 May 1996 19:08:34 +0200 (MET DST), koenig@tat.physik.uni-tuebingen.de (Harald Koenig) said:
Harald> yesterday I run a "virtex" binary from a DEC Unix machine on
Harald> Linux (this one used shared libs; after borrowing
Harald> /sbin/loader and /usr/shlib/libc.so for this test the binary
Harald> run fine) and compared it with the Red Hat binary TeXing
Harald> texbook.tex which is 494 pages plain TeX). this time I used
Harald> /usr/bin/time to get the CPU time and got
Harald> GCC binary : 37 seconds
Harald> DEC-cc & shared : 22 seconds
Harald> which is almost a ratio of 1.7 :-(
You have to be a little careful with making conclusions here. First,
the DEC libraries are generally well optimized. Libc (and dare I say
glibc...) has gotten a lot better, but if TeX happens to use a
particular function that hasn't been optimized for the Alpha yet, it
may easily explain the difference. It would be worthwhile to profile
TeX to find out whether this is the case (yes, I'll be working on
glibc soon, so you'll be able to profile optimized binaries...).
A second caveat is that using a different library (and particularly a
shared library), you get a completely different layout of your code.
This is important since most caches are direct-mapped on Alpha
systems. The only exception to this rule is the second-level cache in
the EV5, which is 3-way set associative. If TeX happens to have a few
tight loops that, in the Linux libc case, are unlucky enough to thrash
in the i-cache, then this again could easily explain the difference.
--david
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: times(2) no sys_call ??
1996-05-10 4:42 David Mosberger-Tang
@ 1996-05-10 7:53 ` Harald Koenig
1996-05-10 7:53 ` Harald Koenig
1 sibling, 0 replies; 7+ messages in thread
From: Harald Koenig @ 1996-05-10 7:53 UTC (permalink / raw)
> This seems the "standard" value. It's the same value that glibc uses.
> I don't think there is anything in POSIX requires CLK_TCK to equal HZ.
> And since OSF/1 uses 60 as well, it's probably better to stick with
> that value.
>
> IMHO: avoid times() if you can...
but why is times() no real system call to sys_times() in linux/kernel/sys.c ?
Harald
--
All SCSI disks will from now on ___ _____
be required to send an email notice 0--,| /OOOOOOO\
24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
Harald Koenig, \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik // / \\ \
koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: times(2) no sys_call ??
1996-05-10 4:42 David Mosberger-Tang
1996-05-10 7:53 ` Harald Koenig
@ 1996-05-10 7:53 ` Harald Koenig
1 sibling, 0 replies; 7+ messages in thread
From: Harald Koenig @ 1996-05-10 7:53 UTC (permalink / raw)
> This seems the "standard" value. It's the same value that glibc uses.
> I don't think there is anything in POSIX requires CLK_TCK to equal HZ.
> And since OSF/1 uses 60 as well, it's probably better to stick with
> that value.
>
> IMHO: avoid times() if you can...
but why is times() no real system call to sys_times() in linux/kernel/sys.c ?
Harald
--
All SCSI disks will from now on ___ _____
be required to send an email notice 0--,| /OOOOOOO\
24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
Harald Koenig, \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik // / \\ \
koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: times(2) no sys_call ??
@ 1996-05-10 15:51 David Mosberger-Tang
0 siblings, 0 replies; 7+ messages in thread
From: David Mosberger-Tang @ 1996-05-10 15:51 UTC (permalink / raw)
>>>>> On Fri, 10 May 1996 09:53:00 +0200 (MET DST), koenig@tat.physik.uni-tuebingen.de (Harald Koenig) said:
>> This seems the "standard" value. It's the same value that glibc
>> uses. I don't think there is anything in POSIX requires CLK_TCK
>> to equal HZ. And since OSF/1 uses 60 as well, it's probably
>> better to stick with that value.
>>
>> IMHO: avoid times() if you can...
Harald> but why is times() no real system call to sys_times() in
Harald> linux/kernel/sys.c ?
If memory serves, that system call wasn't enabled for the Alpha until
work on glibc started. OSF/1 doesn't have that syscall so it probably
was felt that Linux/Alpha wouldn't need it either (which is true,
strictly speaking).
Here is the situation with glibc: it uses the real system call, but it
currently has CLK_TCK defined as 60. This is wrong so I fixed it to
use HZ instead. I hope the patch will show in the regular glibc
sources soon.
So, CLK_TCK on the Alpha will be 1024, not 60 as under OSF/1. But
that is OK, since OSF/1 doesn't use the times syscall to implement
times().
As I said: avoid times if you can... :-)
--david
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: times(2) no sys_call ??
1996-05-10 5:07 David Mosberger-Tang
@ 1996-05-17 9:11 ` Harald Koenig
0 siblings, 0 replies; 7+ messages in thread
From: Harald Koenig @ 1996-05-17 9:11 UTC (permalink / raw)
> Harald> yesterday I run a "virtex" binary from a DEC Unix machine on
> Harald> Linux
> Harald> GCC binary : 37 seconds
> Harald> DEC-cc & shared : 22 seconds
>
> You have to be a little careful with making conclusions here. First,
> the DEC libraries are generally well optimized. Libc (and dare I say
> glibc...) has gotten a lot better, but if TeX happens to use a
> particular function that hasn't been optimized for the Alpha yet, it
> may easily explain the difference.
I've tried to get some more information what's the difference between
those binaries (first idea was to link DEC-CC *.o files with Linux libs
or vice versa but this failed) so I rebuild virtex from the same source
tree using both gcc and DEC cc.
to my surprise I wasn't able to build a "slow" linux binary!
both the Linux/gcc and DEC/cc binaries needed ~22-23 sec for the texbook
using
-rw-r--r-- 1 root root 1801432 Apr 2 23:39 gccaxp-2.7.1-3.axp.rpm
-rw-r--r-- 1 root root 519185 Apr 9 21:34 libcaxp-0.43-1.axp.rpm
and
-rw-r--r-- 1 root root 10355690 Apr 9 22:36 tetex-0.3.3-10.src.rpm
I've extracted the virtex binary (and plain.fmt) from both Red Hat
AXP 2.1 and 3.0.3 CDs
-rwxr-xr-x 1 root users 622592 Dec 20 22:20 virtex-2.1*
-rwxr-xr-x 1 root root 630784 Apr 10 18:38 virtex-3.0.3*
and both are slow (~37 secs). does anyone know how this binary was built
and which libc version was used ?
Harald
--
All SCSI disks will from now on ___ _____
be required to send an email notice 0--,| /OOOOOOO\
24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
Harald Koenig, \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik // / \\ \
koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1996-05-17 9:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-05-10 15:51 times(2) no sys_call ?? David Mosberger-Tang
-- strict thread matches above, loose matches on Subject: below --
1996-05-10 5:07 David Mosberger-Tang
1996-05-17 9:11 ` Harald Koenig
1996-05-10 4:42 David Mosberger-Tang
1996-05-10 7:53 ` Harald Koenig
1996-05-10 7:53 ` Harald Koenig
1996-05-09 17:08 Harald Koenig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox