Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jan 2011 21:55:06 -0800
From:      Robby Sun <robbysun@gmail.com>
To:        Slawa Olhovchenkov <slw@zxy.spb.ru>
Cc:        freebsd-performance@freebsd.org, Julian Elischer <julian@freebsd.org>, Bruce Evans <brde@optusnet.com.au>, Stefan Lambrev <stefan.lambrev@moneybookers.com>
Subject:   Re: Interrupt performance
Message-ID:  <AANLkTimP4RybWKY_Qhuv6mi0%2BVNVASJUL3rxy-eoy6z_@mail.gmail.com>
In-Reply-To: <20110128215215.GJ18170@zxy.spb.ru>
References:  <20110128143355.GD18170@zxy.spb.ru> <22E77EED-6455-4164-9115-BBD359EC8CA6@moneybookers.com> <20110128161035.GF18170@zxy.spb.ru> <CDBFAB7F-1EBC-4B3A-B2F5-6162DD58A93D@moneybookers.com> <4D42F87C.7020909@freebsd.org> <20110128172516.GG18170@zxy.spb.ru> <20110129070205.Q7034@besplex.bde.org> <20110128215215.GJ18170@zxy.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
I'd like to suggest that you use the same bit-width for 'Dummy' as that for
'count', and initialize it to 0, so as to ensure that it won't overflow.

-Robby

On Fri, Jan 28, 2011 at 1:52 PM, Slawa Olhovchenkov <slw@zxy.spb.ru> wrote:

> On Sat, Jan 29, 2011 at 07:52:11AM +1100, Bruce Evans wrote:
>
> > >> there are of course several possible answers, including:
> > >>
> > >> 1/ Sometimes BSD and Linux report things differently. Linux may or may
> not
> > >> account for the lowest level interrupt tie the same as BSD
> > >
> > > But I see only 20% idle on FreeBSD and 80% idle on Linux.
> >
> > The time must be counted somewhere, so when it is not properly accounted
> > to packet handling, and nothing much else is running, it is accounted to
> > idle.
> >
> > To see how much CPU is actually available, run something else and see how
> > fast it runs.  A simple counting loops works well on UP systems.
>
> ===
> #include <stdio.h>
> #include <sys/time.h>
>
> int Dummy;
>
> int
> main(int argc, char *argv[])
> {
>  long int count,i,dt;
>  struct timeval st,et;
>
>  count = atol(argv[1]);
>
>  gettimeofday(&st, NULL);
>  for(i=count;i;i--) Dummy++;
>  gettimeofday(&et, NULL);
>  dt = (et.tv_sec-st.tv_sec)*1000000 + et.tv_usec-st.tv_usec;
>  printf("Elapsed %d us\n",dt);
> }
> ===
>
> This is ok?
>
> ./loop 2000000000
>
> FreeBSD
> 1 process: Elapsed 7554193 us
> 2 process: Elapsed 14493692 us
> netperf + 1 process: Elapsed 21403644 us
>
> Linux
> 1 process: Elapsed 7524843 us
> 2 process: Elapsed 14995866 us
> netperf + 1 process: Elapsed 14107670 us
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimP4RybWKY_Qhuv6mi0%2BVNVASJUL3rxy-eoy6z_>