FDEVENTs implementation for linux-2.4.3

OLD CODE

This work is old. I never got around to finishing it. I suggest you just use epoll.
See the following info:
man epoll_create
man epoll_wait
man epoll_ctl

What is here?

This work is based on a discussion on the linux-kernel mailing list with regards to the unscalability of select/poll and how it should be fixed. Linus proposed an implementation which was more scalable then poll/select and better on resource than RT signals. The work bellow is based on the discussions that took place following the debate.

If you are interested in this kind of stuff you may also look at kevents for BSD; there is an article at openmagazine about it.

Why are you doing this?

It just so happened that a few months after this discussion was forgotten there was a need for such a performance boost at my work (Chrysalis-ITS). The work you see here is being done in hopes to improve performance of proxies which handle an order of 10's of thousands of connections; hence 10s of thousands of file descriptors. When a poll/select call is done the array returned must be scanned for data. The descriptors that fire are at most a magnitude less than the number of sockets... yet the whole array must be scanned. This leads to very poor performance.

How will I use it?

Here is a sample TCP-echo server (telnet to port 9999), the package includes automake/autoconf so it's a bit bloated, and you will have to download one of the patches (below) to get it to work:

Here is the basic idea:

	#include <linux/fdevent.h>
	
	static void handler(bind_event *);
	
	...
	
	int fd;
	struct fdevent ev;
	void* something;
	
	fd = socket(...);  /* or open() */
	
	ev.fd = fd;
	ev.mask = FDEVENT_IN;
	ev.data = something;
	ev.fn   = handler;
	
	sys_bind_event(&ev);
	
	...
	
	for(;;) {
	
	  bind_event events[DESIRED_MAX];
	
	  num = sys_get_events( &events, DESIRED_MAX, SLEEP_IN_MS );
	  for(i=0; i<num; i++)
	    events[i].fn( &events[i] );
	  
	}

What is missing?

This is my TODO list in order of decreasing importance

So, what is done?

The patches below are in reverse order; the one at the top is the one you want, as it is most current.



Bart Trojanowski
http://www.jukie.net/~bart
bart@jukie.net