Monday, January 17, 2011

Understanding Multi-Core Multi-Thread Performance

Let's say we have 2 mutant octopus of a new species. Let's say Octopus-A has 2 mouths and 32 tentacles. Octopus-B has 4 mouths and 16 tentacles. Which one do you think will consume food at a faster rate at an all-you-can-eat buffet?

The answer depends heavily on one variable: how fast the octopus use their tentacles to put food into mouths.

To illustrate by analogy, a web server under high load is like an above octopus at an all-you-can-eat buffet where there are more food than tentacles and mouths combined. A web server is good at juggling request processing and response handling.

Next, let's consider the difference between CPU-bound and I/O-bound. Instead of an all-you-can-eat buffet, it gets more interesting now if we take Octopus-A and Octopus-B to an all-you-can-cook dinner. There are still more food than mouths and tentacles combined, but only a fixed amount of pots to cook food with. How would that slow down the performance if any?

Given an octopus (aka computer) does not know how to think on its own, it needs to be programmed. In an extreme case, an octopus could be starved if it is programmed to be occupied with cooking food items in pots, because this extreme-case CPU-bound octopus is programmed to cook (aka process) first and eat later.

We could also teach the octopus about I/O-bound in order to strike a better balance between cooking and eating. In this case, let's say the octopus has a personal chef who cooks whatever food the octopus gives to him. The octopus will now be programmed to eat while waiting to get more cooked food from the chef.




















No comments:

Post a Comment