Week 08 Workshop

Preparation

Before the workshop you should have watched the lectures. Some workshops have pre-workshop tasks which are optional, but useful. Completing labs before workshops is also optional (but may be useful)!

Exercise:
Workshop 8 - Async Scheduling

Last week, we worked on a scheduler system. This week (and maybe next week), we'll extend that system to work asynchronously.

Please use the same code you got last week! You can download a new set of tasks here. As part of pre-workshop work, integrate these tasks into your existing code (as synchronous tasks).

Have you ever felt like pop music is all the same? We wanted to find out, by getting a data-set from two of the most popular artists of our generation; and comparing them. In the starter code for this week, you'll find the lyrics of Taylor Swift, and Coldplay. We have written code which scans in these data-sets; builds a word-frequency hashmap, and then does some comparisons.

While the data may be interesting, your task is to speed this code up, using parallelism. To start, your tutor will have a short discussion with you about the different concurrency primatives you've seen in the course so far.

Once you've done that, try changing your scheduler system so that it runs tasks in parallel.

After that, see if you can use concurrency to improve the speed of it further. Some ideas which might help:

  • Use rayon to make some of the sequential calculations faster
  • Use a RWLock so multiple threads can access the hashmaps at the same time.
  • Split existing tasks into smaller tasks which can be parallelised.

If you have time at the end, modify the code to count the number of identical lines in each artist's songs.