cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: a curl_multi_fdset() replacement? (TODO-RELEASE #55)

From: Ben Greear <greearb_at_candelatech.com>
Date: Mon, 31 Jan 2005 15:29:03 -0800

codemstr_at_ptd.net wrote:
>>select() is fine except for two problems:
>
> Select also wastes memory. An fd_set is usually implemented as including an
> array of FD_SETSIZE entries. Therefore, if FD_SETSIZE is 1024, even if I'm
> only using select() to deal with a single socket, it's still allocating
> enough memory to hold 1024. Poll solves this by using a dynamically allocated
> storage.

1024 fds is one small 4k page of memory. Unless you are on a very small system,
this is meaningless. poll, on the other hand, requires a linked list of structures.
Unless you are clever and put a bunch of these in an array and handle the dynamic
allocation yourself, walking this list is going to thrash your cache and be much
slower than just accessing a single page of memory.

Ben

-- 
Ben Greear <greearb_at_candelatech.com>
Candela Technologies Inc  http://www.candelatech.com
Received on 2005-02-01