Testing efficiency of select()/poll() on 100s of sockets

Testing efficiency of select()/poll() on 100s of sockets

Post by Jack Robin » Sun, 22 Dec 2002 11:31:58



Hi All,

Could anyone recommend a way I could test the efficiency of
select()/poll() with say 500 open (TCP) file descriptors.
I'm trying to gauge how much time is taken up by select()/poll()
and how best to handle reading as many fds in one swoop that
I can versus read one fd, put back into FDSET, read another one
etc.

TIA.

jr

 
 
 

Testing efficiency of select()/poll() on 100s of sockets

Post by David Schwart » Sun, 22 Dec 2002 12:54:17



> Hi All,

> Could anyone recommend a way I could test the efficiency of
> select()/poll() with say 500 open (TCP) file descriptors.
> I'm trying to gauge how much time is taken up by select()/poll()
> and how best to handle reading as many fds in one swoop that
> I can versus read one fd, put back into FDSET, read another one
> etc.

> TIA.

> jr

        Call select/poll, do all the I/O, call select/poll again. This way, the
select/poll overhead decreases as load increases.

        DS

 
 
 

Testing efficiency of select()/poll() on 100s of sockets

Post by Jack Robin » Mon, 23 Dec 2002 02:40:00


David, Thanks for the recommendation.

David, All, I was hoping to evaluate how long it took for
select()/poll() to run through the FDSET argument. That is, say
I use select() with maxfds set to 1024, however, I
only have 10 fds set at any given time. So, then its either I
manage what the maxfds+1 value so that select() has some idea of
how far to look into the FDSET bitmap or if I just let it be 1024
then regardless of the number of active fds, the cost of doing a
select() should remain constant?

Is there a way to measure that time?

Thanks,

jr



>> Hi All,

>> Could anyone recommend a way I could test the efficiency of
>> select()/poll() with say 500 open (TCP) file descriptors.
>> I'm trying to gauge how much time is taken up by select()/poll()
>> and how best to handle reading as many fds in one swoop that
>> I can versus read one fd, put back into FDSET, read another one
>> etc.

>> TIA.

>> jr

> Call select/poll, do all the I/O, call select/poll again. This way, the
> select/poll overhead decreases as load increases.

> DS

 
 
 

Testing efficiency of select()/poll() on 100s of sockets

Post by Michael Fu » Mon, 23 Dec 2002 10:40:55



> David, All, I was hoping to evaluate how long it took for
> select()/poll() to run through the FDSET argument. That is, say
> I use select() with maxfds set to 1024, however, I
> only have 10 fds set at any given time. So, then its either I
> manage what the maxfds+1 value so that select() has some idea of
> how far to look into the FDSET bitmap or if I just let it be 1024
> then regardless of the number of active fds, the cost of doing a
> select() should remain constant?

> Is there a way to measure that time?

You could call gettimeofday(), then call select()/poll() a bunch
of times (like thousands or millions, depending on how fast your
machine is) with a timeout of 0 so the calls don't block, then call
gettimeofday() again, then figure out the difference between the
start and end times.  Try this with various values of nfds, where
nfds is the first argument to select().  Compare the results for
select() to the results for poll().  This is a simplistic test, but
it might be good enough for what you're trying to measure.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

 
 
 

Testing efficiency of select()/poll() on 100s of sockets

Post by Jack Robin » Mon, 23 Dec 2002 11:48:25




>> David, All, I was hoping to evaluate how long it took for
>> select()/poll() to run through the FDSET argument. That is, say
>> I use select() with maxfds set to 1024, however, I
>> only have 10 fds set at any given time. So, then its either I
>> manage what the maxfds+1 value so that select() has some idea of
>> how far to look into the FDSET bitmap or if I just let it be 1024
>> then regardless of the number of active fds, the cost of doing a
>> select() should remain constant?

>> Is there a way to measure that time?

> You could call gettimeofday(), then call select()/poll() a bunch
> of times (like thousands or millions, depending on how fast your
> machine is) with a timeout of 0 so the calls don't block, then call
> gettimeofday() again, then figure out the difference between the
> start and end times.  Try this with various values of nfds, where
> nfds is the first argument to select().  Compare the results for
> select() to the results for poll().  This is a simplistic test, but
> it might be good enough for what you're trying to measure.

thanks.
 
 
 

Testing efficiency of select()/poll() on 100s of sockets

Post by Ian » Tue, 24 Dec 2002 13:49:47


Have a look with your de*, some implementations call poll from
select, so there is no contest.

Ian


> Hi All,

> Could anyone recommend a way I could test the efficiency of
> select()/poll() with say 500 open (TCP) file descriptors.
> I'm trying to gauge how much time is taken up by select()/poll()
> and how best to handle reading as many fds in one swoop that
> I can versus read one fd, put back into FDSET, read another one
> etc.

> TIA.

> jr

 
 
 

1. Finding out what happened on a socket (with select or poll)?

Hi,

I am porting some code from win32 to linux, and am having a few
difficulties working my way around the sockets implementation. Almost
everything works fine, until I try to work on the asynchronous stuff.

In win32, I can call a WSAWaitForMultipleEvents (which does roughly
the equivalent of select) and then when it returns, I can find out
what events have fired on a given socket by calling
WSAEnumNetworkEvents. This returns a bitmask with values like
FD_ACCEPT, FD_READ and FD_WRITE which indicate what events are waiting
on that socket.

I can see no way to find out what I should be doing after a select.
For example, how do I know if the select is returning because I have
successfully connected? Previously I would just check for FD_CONNECT.
Basically, I just want to know how to know what action to carry out
after a select (or alternatively a poll).

Also, can you tell me if it is bad and evil to use select in a
single-connection thread? I want to be able to stop individual servers
whether they are waiting for I/O or not. The fact that select has a
timeout allows me to do this by checking a value whereas just calling
recv would not. Is this a bad way to do things?

Thanks in advance,
--
Simon Steele
Softel Ltd.

2. Problem connecting ISP

3. poll/select in udprelay - anyone have poll.c(h) code for linux?

4. previous PPP posting

5. test test test test test test test

6. Sun Solaris PC version software

7. Select vs Poll

8. how do you switch between X servers?

9. select, poll, and others

10. poll() or select() ?

11. Converting select() calls to poll()

12. Close notification in poll/select (works on all OS except Linux)

13. Select/Poll says data pending but subsequent read blocks.