From: Josef Sipek <jsipek@fsl.cs.sunysb.edu>
To: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: bert hubert <bert.hubert@netherlabs.nl>,
Andi Kleen <andi@firstfloor.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: all syscalls initially taking 4usec on a P4? Re: nonblocking UDPv4 recvfrom() taking 4usec @ 3GHz?
Date: Tue, 20 Feb 2007 13:42:42 -0500 [thread overview]
Message-ID: <20070220184242.GA30077@filer.fsl.cs.sunysb.edu> (raw)
In-Reply-To: <20070220164124.GA24930@2ka.mipt.ru>
On Tue, Feb 20, 2007 at 07:41:25PM +0300, Evgeniy Polyakov wrote:
> On Tue, Feb 20, 2007 at 05:27:14PM +0100, bert hubert (bert.hubert@netherlabs.nl) wrote:
> > I've done so, with some interesting results. Source on
> > http://ds9a.nl/tmp/recvtimings.c - be careful to adjust the '3000' divider
> > to your CPU frequency if you care about absolute numbers!
> >
> > These are two groups, each consisting of 10 consecutive nonblocking UDP
> > recvfroms, with 10 packets preloaded. Reported is the number of microseconds
> > per recvfrom call which yielded a packet:
> >
> > $ ./recvtimings
> > 4.142333
>
> It can be recvfrom only problem - syscall overhead on my p4 (core duo,
> debian testing) is bout 300 usec - to test I ran
> read('dev/zero', &data, 0)
> in a loop.
A better thing would be to use getuid - it turns into just a return with a
memory dereference). I ran it on my 3.06GHz P4 (HT, but only UP kernel),
PREEMPT, HZ=1000...
3.290196 0.470588 0.402614 0.396078 0.393464 0.396078 0.386928 0.386928 0.386928 0.386928
0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928
0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928
0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928 0.386928
I used the rdtsc instruction to measure the time for the getuid syscall (see
bellow for source to the test app).
---8<-------------
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
/* CPU speed in MHz */
#define CPUFREQ 3060
#define rdtscll(val) \
__asm__ __volatile__("rdtsc" : "=A" (val))
int main()
{
unsigned long long start, end;
int i;
for(i=0;i<10000;i++) {
rdtscll(start);
getuid();
rdtscll(end);
printf("delta for syscall: %llu cycles = %f us\n", end-start, (end-start)/(float)CPUFREQ);
}
return 0;
}
---8<-------------
Josef "Jeff" Sipek.
--
Research, n.:
Consider Columbus:
He didn't know where he was going.
When he got there he didn't know where he was.
When he got back he didn't know where he had been.
And he did it all on someone else's money.
next prev parent reply other threads:[~2007-02-20 18:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070219231447.GA4400@outpost.ds9a.nl>
[not found] ` <p73d545drx6.fsf@bingen.suse.de>
2007-02-20 16:27 ` bert hubert
2007-02-20 16:41 ` Evgeniy Polyakov
2007-02-20 17:02 ` bert hubert
2007-02-20 17:11 ` Evgeniy Polyakov
2007-02-20 17:18 ` Evgeniy Polyakov
2007-02-21 11:06 ` Evgeniy Polyakov
2007-02-21 11:34 ` Andi Kleen
2007-02-20 18:42 ` Josef Sipek [this message]
2007-02-20 18:48 ` Evgeniy Polyakov
2007-02-20 19:33 ` bert hubert
2007-02-20 19:40 ` Benjamin LaHaise
2007-02-20 20:45 ` bert hubert
2007-02-20 21:02 ` Stephen Hemminger
2007-02-20 22:02 ` Rick Jones
2007-02-20 22:17 ` bert hubert
2007-02-20 22:22 ` Arjan van de Ven
2007-02-21 16:25 ` Chuck Ebbert
2007-02-20 22:46 ` Ian McDonald
2007-02-25 10:41 ` Pavel Machek
2007-02-25 17:06 ` Evgeniy Polyakov
2007-02-20 16:57 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070220184242.GA30077@filer.fsl.cs.sunysb.edu \
--to=jsipek@fsl.cs.sunysb.edu \
--cc=andi@firstfloor.org \
--cc=bert.hubert@netherlabs.nl \
--cc=johnpol@2ka.mipt.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®