Dear all:
Had anyone heard about uselect()? uselect() is also an interface for web applications to improve the performance like epoll().It provide a user-level connection state tracking mechanism. Kernel and web applications share a piece of memory.There are some fd_sets in this shared memory.Each time the socket is ready to be read or write, the relative bit in shared memory will be set a flag.Most work of uselect() is just check these shared memory, without syscall and context switch, without fd_set copy.When there is no ready sockets,uselect() will block until any of them ready.
User can call Uselect() just like the original select().Uselect() can tracking all sockets created by current process.It need not do registering/unregistering for each sockets like epoll(). This interface need not too much changes on squid.
It can save the CPU time by avoid syscall and data copy. And the overhead is linear to maxfd,because it need to check enough area of the fd_sets in shared memory.But the whole overhead will not more than epoll,because it just access memory in user-level.
I had implement the kernel module of uselect(),and the user interface almost be finished.I want to use this interface at Squid-2.5. But I need help now.
The main problem to use this interface at squid-2.5 is: I do not know, in the original comm_select() loop, how many kinds of fd need to be checked by select()? Currently I see these: filesystem fds(for log files), TCP sockets,UDP sockets,pipes(for aio). My uselect currently can check state of sockets, and can be awaked by aio(thanks the help from Henrik).The next step I want to get rid of filesystem fds. Did I omit some ? Dose aio handle I/O of swap file ?
There are two way to handle filesystem fds:
1.Use aio to write log files,the main thread only handle network I/O(The squid-2.2 originally worked in this way).I think this will be the better method.Because if squid worked in this way, I need not do anything. :)
2.Always return ready for filesystem fds. When commSetSelect() be called to check the fs fds, I put them in another fd tables. Each time uselect() returns, it OR the result fd_set and that fd table.
Any suggestions? Thanks!
Best Regards
Xia Hongtao
htxia@wtwh.com.cn
2004-02-25
Received on Tue Feb 24 2004 - 18:55:32 MST
This archive was generated by hypermail pre-2.1.9 : Mon Mar 01 2004 - 12:00:04 MST