Re: PROBLEM: select() on TCP socket sleeps for 1 tick even if data available

From: James Antill (james@and.org)
Date: Tue Apr 10 2001 - 15:25:43 EST


"Stephen D. Williams" <sdw@lig.net> writes:

> James Antill wrote:
> >
> > I seemed to miss the original post, so I can't really comment on the
> > tests. However...
>
> It was a thread in January, but just ran accross it looking for
> something else. See below for results.

 Ahh, ok.

> > > Michael Lindner wrote:
> ...
> > > > <0.000021>
> > > > 0.000173 select(8, [3 4 6 7], NULL, NULL, NULL) = 1 (in [6])
> > > > <0.000047>
> >
> > The strace here shows select() with an infinite timeout, you're
> > numbers will be much better if you do (pseudo code)...

[snip ... ]

> > ...basically you completely miss the function call for __pollwait()
> > inside poll_wait (include/linux/poll.h in the linux sources, with
> > __pollwait being in fs/select.c).
>
> Apparently the extra system call overhead outweighs any benefit.

 There shouldn't be any "extra" system calls in the fast path. If data
is waiting then you do one call to poll() either way, if not then you
are wasting time blocking so it doesn't matter what you do.

> In any
> case, what you suggest would be better done in the kernel anyway.

 Possibly, however when this has come up before the kernel people have
said it's hard to do in kernel space.

> The
> time went from 3.7 to 4.4 seconds per 100000.

 Ok here's a quick test that I've done. This passes data between 2
processes. Obviously you can't compare this to your code or Michael's,
however...

 The results with USE_DOUBLE_POLL on are...

% time ./pingpong
./pingpong 0.15s user 0.89s system 48% cpu 2.147 total
% time ./pingpong
./pingpong 0.19s user 0.91s system 45% cpu 2.422 total
% time ./pingpong
./pingpong 0.10s user 1.02s system 49% cpu 2.282 total

 The results with USE_DOUBLE_POLL off are...

% time ./pingpong
./pingpong 0.24s user 1.07s system 50% cpu 2.614 total
% time ./pingpong
./pingpong 0.21s user 1.00s system 44% cpu 2.695 total
% time ./pingpong
./pingpong 0.21s user 1.13s system 50% cpu 2.667 total

 Don't forget that the poll here is done with _1_ fd. Most real
programs have more, and so benifit more.

 I also did the TRY_NO_POLL, as I was pretty sure what the results
would be, that gives...

% time ./pingpong
./pingpong 0.03s user 0.41s system 50% cpu 0.874 total
% time ./pingpong
./pingpong 0.06s user 0.44s system 58% cpu 0.855 total
% time ./pingpong
./pingpong 0.07s user 0.35s system 51% cpu 0.820 total




-- 
# James Antill -- james@and.org
:0:
* ^From: .*james@and\.org
/dev/null

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 15 2001 - 21:00:14 EST