Maximizing Real-Life Benefits from Computer Science Concepts
Written on
In today's world, individuals globally are reaping the advantages of computer science on a daily basis. Computing devices have integrated into every aspect of life, allowing people to benefit without needing to understand the underlying principles. This raises an important question: what is the purpose of this discussion?
This series of essays aims to apply essential computer science concepts to enrich real-world experiences. It explores practical uses of computer science while also enhancing the fundamental comprehension of computing mechanisms.
Recently, I embarked on a project that required me to delve into various computer science concepts within a practical framework. This exploration inspired the creation of this series. With that context established, let's dive in.
Can Hand-Blown Glass Production Gain from Computer Science? As an example of a real-world application, let's consider the craft of hand-blown glass. Picture yourself as an artist selling your glass creations. The process of creating each piece involves several steps:
- Pre-heat glass in a furnace to approximately 2000°C — 20 minutes.
- Roll glass on a shaping plate (marver) using a blowpipe — 10 minutes.
- Blow glass into the desired artistic shape with the blowpipe — 10 minutes.
- Cool down the glass in a dedicated cooling furnace — 20 minutes.
The overall production process consists of four steps, taking a total of 60 minutes. While you cherish the art created through this method, as a businessperson, you seek to boost productivity (the number of pieces produced per hour) by slightly modifying the process.
For this goal, you turn to computer science!
The Concept of Parallelism In contemporary computing, fetching information from storage is often much slower than the speed at which processors can handle data. Therefore, when a computer retrieves or sends information, the processor is designed to engage in productive work rather than idle waiting. This is a prime example of parallelism in computer science.
You've likely heard that humans struggle with multitasking. So, how can you enhance the rate of glass production without the challenges of multitasking? There are two main approaches to consider.
To explore the first approach, we can ask:
“Is there any step in the glass-blowing process that can be parallelized?”
Enhancing Production by Dividing Tasks Let's examine the first step: pre-heating the glass. The pre-heating oven has sufficient capacity to accommodate more than one piece of glass at a time. Thus, you can pre-heat a larger quantity of glass than usual.
The second and third steps (rolling and blowing) depend on you as the artist. Initially, they may seem non-parallelizable. However, if you hire an apprentice and impart your skills, procuring an additional blowpipe and safety gear will allow two individuals to work on different pieces simultaneously.
Regarding the cooling furnace, it should have enough space to cool multiple pieces. As a result, your revised production schedule would appear as follows:
By dividing each parallelizable task, you effectively double the production rate per hour! However, there are several considerations to address before finalizing this approach.
The Drawbacks of Dividing Tasks The first notable point is that dividing tasks incurs clear costs. If you opt for this method, you'll need to compensate another person and invest in extra safety equipment, blowpipes, etc.
Additionally, there are hidden costs that might not be immediately apparent. With multiple individuals working simultaneously, effective communication and coordination are essential to ensure efficiency. For instance, you wouldn't want to mistakenly select the wrong piece of glass from the pre-heating furnace.
These types of coordination challenges are prevalent in computer science, commonly referred to as coordination overhead within the context of parallelism. Moreover, if certain tasks in the production sequence are non-parallelizable, the production process will have inherent limits to how much it can be expedited.
For example, if your cooling furnace can only accommodate three pieces, it would become a bottleneck if more than three individuals attempted to divide the production tasks. This point may seem obvious in this example, but real-life task complexities can be deceiving.
Avoiding Missteps in Applying Computer Science In a previous project, my team was tasked with splitting a numerical model among several members. As we encountered challenges with coordination and communication, I suggested that this might not be the best strategy. One of my insightful colleagues quipped:
“Our manager is the kind who thinks ten pregnant women can deliver one baby in one month.”
The lesson here: Avoid being THAT manager! The assumption that adding resources to a parallelizable process will expedite results can be misleading. Task division ceases to be beneficial if part of the process is NOT divisible.
Computer architect Gene Amdahl made significant contributions to understanding the limitations of parallel computing, which are encapsulated in Amdahl’s Law. If you're interested in the technical specifics, I encourage you to explore this concept.
If you're not inclined to hire an apprentice or invest in new equipment and prefer to enhance your output without incurring additional costs, consider the second significant method of parallelism: Pipelining.
The Concept of Pipelining Pipelining enhances process efficiency by executing multiple tasks at various stages of completion concurrently. This concept becomes clearer with an illustrative example.
Imagine you intend to produce multiple pieces of artwork in a single day. Each piece consists of a batch, with batch-2 following batch-1, batch-3 following batch-2, and so forth. However, batches do not have to follow sequentially. The updated production schedule would look like this:
In this scenario, the pre-heating furnace heats glass for all three batches simultaneously. From 07:20 AM to 07:40 AM, you work on rolling and blowing batch-1. As batch-1 enters the cooling furnace, you can begin rolling and blowing batch-2.
This means that the cooling phase of batch-1 occurs alongside the rolling and blowing steps of batch-2. For illustration, I've assumed that the transition from placing batch-1 in the cooling furnace to starting batch-2 is nearly instantaneous.
In summary, this schedule may seem paradoxical. Each batch still requires 60 minutes to finish, yet you end up producing three pieces of artwork in 100 minutes. How can this be? (More on that in a moment.) You transition from producing one piece of artwork per hour to approximately 1.8 pieces.
This illustrates the power of pipelining, as it emphasizes the entire sequence of tasks rather than just individual tasks — a holistic approach.
Understanding Latency and Throughput The apparent paradox, where each batch still takes 60 minutes but results in more than one artwork piece produced in an hour, can be clarified through the concepts of latency and throughput in computer science. Latency pertains to individual tasks — it measures the speed of completing each task. Conversely, throughput addresses the entire process — it measures the overall speed of task completion.
Thus, while dividing tasks among workers enhances latency, pipelining boosts throughput. In our example, pipelining did not improve latency; each task still took the same amount of time as before. However, throughput increased due to more effective scheduling.
Final Thoughts on Leveraging Computer Science The principle of parallelism is invaluable for enhancing process efficiency, particularly when the process exhibits repeating patterns. To implement parallelism effectively, consider the following steps:
- Identify parallelizable tasks and divide them among various workers/processors.
- Recognize that non-parallelizable tasks set limits on how many workers/processors can efficiently handle the parallelizable tasks.
- Avoid the misconception that simply adding more resources to a parallel process will accelerate it. Factor in coordination overhead and plan accordingly.
- Explore pipelining if your process allows for simultaneous task execution, as it can be a powerful time-saving tool.
I've had the privilege of working on processes that require no communication overhead, known as “embarrassingly parallel” in computing. However, such instances are rare in real life. By adhering to the guidelines outlined above, you can effectively harness the benefits of parallelism.
If this discussion has provided insights or solutions to your unique challenges, please share your experiences in the comments. I plan to delve into additional computer science concepts that can enhance our daily lives in subsequent essays.
For further reading, you might find interest in Why Are Analogue Computers Really On The Rise Again? and How To Really Understand The Concept Of An Algorithm?
If you'd like to support my work as an author, please consider contributing on Patreon.
You can read the original essay here.