system call overhead

tuxillo at quantumachine.net tuxillo at quantumachine.net
Sun May 11 07:36:46 PDT 2014


On 2014-05-11 12:38, Wojciech Puchar wrote:
> did a simple test under FreeBSD/amd64 on intel atom 1.8GHz
>
> #include <stdio.h>
> #include <sys/types.h>
> #include <unistd.h>
> main() {
>  int a;
>  for(a=0;a<10000000;a++) read(0,(void*)&a,0);
> }
>
>
> takes over 5 seconds (10^10 cycles) to execute system call doing
> nothing 10^7 times. it did this in a loop so even no cache refill
> effect should make a difference.
>
> so 1000 CPU cycles on 2-way superscalar in-order CPU per system call
> with everything in L1 cache. for me it is way too much.
>
> Huge overhead of passing through ancient x86 gate descriptors are not
> present - FreeBSD uses syscall instruction.
>
> i found that doing other system calls that too do - in effect -
> nothing, doesn't change that figure much.
>
> tried to browse FreeBSD sources and found it quite complex.
>
> As i for now don't have dragonfly installed on real computer at
> present (VM is not a place to make good test) so could anyone perform
> that test on dragonfly?

Hi,

On a i5 2500K (x64):

antonioh at i5:~/temp$ time ./t_syscall
0.117u 1.390s 0:01.50 100.0%    2+66k 0+0io 0pf+0w

But for details see this ktrace dump: 
http://leaf.dragonflybsd.org/~tuxillo/archive/temp/ktrace_t_syscall.out.xz

Cheers,
Antonio Huete





More information about the Users mailing list