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

Re: [apache-plusplus] Process model ideas for C++ Apache.



Michael Anderson wrote previously:
> > If fibers can not be spread across multiple CPUs, isn't there
> > a good possibility that a process with many fibers (say 300)
> > will be starving many of its fibers since the process is
> > competing for CPU (one CPU at a time) with all the other
> > processes in the system?

Dean Gaudet wrote:
> There's another aspect to http requests... they generally
> don't require a lot of computing time in userland... most
> of what they do is tell the kernel to send some bytes
> somewhere.  The user-level threads packages generally context
> switch immediately when a write/read would block.  Then
> they'll work a bit on another request, and maybe switch
> again... a bunch can happen within one kernel context-switch.

Whoa! What have I been thinking ... When talking about pure
fibers, the model I described will perform exactly as Dean's
description above. Both CVs (condition variables) and mutexes
are light-weight user-level. Dean's process model paper describes
fibers as "co-operatively multi-tasked, with context switching
occuring only at I/O points or at explicit yield points."
Therefore, the heavy context-switch we are berating does not
happen! The advantages of fewer threads still exists.

Now for hybrid systems, depending on the implementation, there
may be a context-switch or not for CVs. The disadvantage could
be a heavy context-switch; the advantage would then be that the
multiple functions could be spread across multiple CPUs.



If the performance of these two differing process models is
roughly equivalent, which benchmarking across different
threading models would tell us, the differences boil down
to programming ease vs. features and capabilities. I think
Ben's comment that a way to switch among process models
according to the platform and features of the program are
appropriate.

Regards,

-- 
Mike Anderson
mka@redes.int.com.mx
+52 473 23730 voice/fax
Guanajuato, GTO, Mexico

"If it looks like a bug, waddles like a bug,
and quacks like a bug, its a quack!"