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 <bouyer%antioche.eu.org@localhost> 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().

The point about writev() is that the write is (more or less) atomic.
This wouldn't be true for a sequence of write() system calls.

Although your code reports a significant time inside write(), I'd suspect
that the system call entry/exit are not responsible.
So merging the code into a single system call would gain very little.

System calls that don't block aren't that expensive on most sane
architectures (ie those that don't need a cache flush to avoid userspace
accessing kernel addresses after the call returns).

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index