perforamce ◦ Running example ◦ Parallel programming ▪ Parallelizing processing with pmap ▪ Choosing the optimal number of threads ▪ Reducers • Removing wasteful intermediate results • Parallelizing processing with fold ◦ Type hints 2
Art of Concurrency: A Thread Monkey’s Guide to Writing Parallel Applications Parallel is a subset of concurrent Parallel in progress at the same time executed simultaneously Are multi cores required? task1 task1 task2 task2 Two or more actions can be .. Execution example Yes No Concurrent resumed task1
perforamce ◦ Running example ◦ Parallel programming ▪ Parallelizing processing with pmap ▪ Choosing the optimal number of threads ▪ Reducers • Removing wasteful intermediate results • Parallelizing processing with fold ◦ Type hints 5
applications with many threads, and have significant costs wc Threads Execution time in second 1 1,000,000 wc-p 1.059627 4.964622 Length of the arument 1,000,000 Execution time, MacBook Pro (Retina, 13-inch, Early 2015) 1,000,000
reducef coll) • the collection is paritioned into groups • combinef ◦ associative: a (bc) = (ab) c ◦ takes the result of applying reducef to each group ◦ must produce its identity value, when called with no arguments • reducef ◦ reduces each group ◦ like a function which is passed to reduce https://clojure.org/reference/reducers
perforamce ◦ Running example ◦ Parallel programming ▪ Parallelizing processing with pmap ▪ Choosing the optimal number of threads ▪ Reducers • Removing wasteful intermediate results • Parallelizing processing with fold ◦ Type hints 16