[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [apache-plusplus] Applications for HTTP servers (was "Process model for C++ Apache")
>> >> 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?
>> >
>> >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.
>>
>> Is this the case for hybrid systems as well? I was under the impression
>> that they amount to basically a mapping 'twixt user-level threads and
>> kernel-threads, so I wouldn't expect to see the same problems... is that
>> actually the case?
>> As I understand it, Michael, the problem you refer to can happen when
>> _only_ fibers are used. I believe hybrid systems can compensate somewhat,
>> perhaps at the cost of many context-switches... but I thought this was not
>> the case. Dean, can you help out here?
>
>They're an MxN mapping -- M doesn't have to be the same as N. It's a
>multiplexing operation between user-level threads and kernel-level
>threads. So it's still the case.
I sit corrected!!! :)
Guess I kinda forgot about the MxN part... sorry, I'm still kinda learning
all the fine details as we go along here... :)
Now that I think about it, it makes sense... if you have multiple
user-level threads mapping to a single kernel thread, possibly even
shifting those mappings over time, you still wind up with several context
switches. But is it still as bad?
For example, I've got five kernel threads. I've also got twenty fibers...
for simplicity, say the mapping is even, four fibers to a thread. Now,
I've got five kernel-based context-switches, each of which may include four
user-level context-switches. Is that really as bad as twenty kernel-level
context switches?
Just curious... I'm trying to gain a better understanding of threading
subtlety.
- Bret -