Worksheet 12

64 hungry cats & Race Conditions Over Cold Broken Pizza

Bugcat joins his classmates (64 cats in total) at the CS department’s 導生聚. Ms. Kitty kindly orders a 16-inch Hawaiian pizza through Uber Eat.

Bugcat proposes to everyone:

“Hey! Let’s divide and conquer! We’ll cut the pizza into 64 slices so everyone gets one. That way, we finish eating 64x faster, before it gets cold!”

The cats cheer. Until… they actually start cutting.

Each slice must have at least one piece of ham and pineapple. Half the cats are measuring, the others are picking up dropped pineapples. By the time they finish slicing, the pizza became cold.

Bugcat meows: Why isn’t parallel cutting/eating faster and we end up with cold broken pizza?

Friend: First, Uber Eat delivery is non-parallelizable. Second, so many cats cutting the pizza with shitty plastic knives is just a disaster.

Another friend: “Amdahl’s Law says that even if 64 cats work in parallel, the non-parallelizable will dominate.

“Not to mention the knife contention 🍴 !”

#Parallelized Hunger, #Paralyzed cats, #Zero Speedup

Video Lecture

Remember to open the English subtitle on Youtube: eLearn link of the video lecture

If some people are fast and some people are slow, in the end, everyone is slow.

Readings

Learning Objectives

I understand the following concepts:

  • Difference and trade-off between process and thread
  • Two main motivations for multithreading: latency-oriented concurrency and throughput-oriented parallelism
  • I understand Amdahl’s Law and how to compute the theoretical speedup
  • Why real-world performance often fails to reach the Amdahl’s Law
  • Load imbalance in fork-join pattern
  • Thread pool
  • The Universal Scalability Law
  • The bottleneck in a parallel program is not always the CPU; memory, I/O can also be the bottleneck.
  • How event-driven (AsyncIO) server uses a non-blocking I/O model to efficiently manage lots of concurrent I/O-bound connections. (Lab: Even-driven I/O)
  • The performance of a thread pool is limited by its pool size (Lab: Even-driven I/O)
Back to top