tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Writing to multiple descriptors with one system call

On Wed, Mar 17, 2010 at 03:40:13PM +0000, Sad Clouds wrote:
> On Wed, 17 Mar 2010 16:07:04 +0100
> Manuel Bouyer <> wrote:
> > On Wed, Mar 17, 2010 at 12:50:51PM +0000, Sad Clouds wrote:
> > > [...]
> > > I profiled a simple event driven server, with 5000 simultaneous
> > > connections. About 80% of the time was spent in write() system call.
> > 
> > What makes you think that a syscall writing the same data to multiple
> > descriptors would be faster ?
> > My guess is that the time is not spent in the syscall code itself,
> > but in the socket code (or TCP). 
> I don't know how much improvement it would make, but I thought it would
> cut down on context switching. Same reason why single writev() performs
> better than multiple write().

That it might, but I'm having a hard time seeing how you'd actually use it.
Do you have a delay in each connection to allow for that connections response
to be sent along with any other connections responses?  How do you figure out
which connections are having the same data sent?  It seems like the overhead
of coordinating all that might outweigh any benefit you get from fewer context
If you can flesh out the usage model it a bit, and maybe even write a sample
program, it'd be easier to figure out whether this makes sense to do.  A
simple user space wrapper function around the write() call would let you 
do everything except the performance testing.


Home | Main Index | Thread Index | Old Index