Chapter 6. Parallelism

 

This chapter covers

  • Exploring the importance of parallelism
  • Examining concurrency versus parallelism
  • Getting to know threads in Nim
  • Advanced parsing of data using regular expressions and other means
  • Parallelizing the parsing of large datasets

Every computer program performs one or more computations, and these computations are usually performed sequentially. That is, the current computation has to complete before the next one starts. For example, consider a simple calculation, (2 + 2) x 4, in which the addition must be computed first, to give 4, followed by the multiplication, to give 16. In that example, the calculation is performed sequentially.

Concurrency allows more than one computation to make progress without waiting for all other computations to complete. This form of computing is useful in many situations, such as in an I/O application like the chat application you developed in chapter 3. If executed sequentially, such applications waste time waiting on input or output operations to complete. Concurrency allows this time to be used for another task, drastically reducing the execution time of the application. You learned about concurrency in chapter 3; in this chapter, you’ll learn about a related concept called parallelism.

6.1. Concurrency vs. parallelism

6.2. Using threads in Nim

6.3. Parsing data

6.4. Parallelizing a parser

6.5. Dealing with race conditions

6.6. Summary

sitemap