Table of Contents

Read Copy Update

Task assignment

Imagine that you are developing a multi-threaded application which proceeds concurrently many read and some write requests on a shared data structure. Your goal is to speed up the application so that there is as much read operations as possible while keeping the same amount of write operations.

Steps

  1. Download a naive implementation with mutexes from git repository:
    git clone https://gitlab.fel.cvut.cz/matejjoe/rcu.git
  2. Compile the program (simply run make in rcu directory)
  3. Run the program (./list_mutex <number of reader threads>) and measure read operations and their scalability
  4. Replace the mutexes with rwlocks and measure improvement
  5. Replace list with liburcu (userspace RCU library) list and measure improvement
  6. For rwlocks and librcu, measure reads with various number of reader threads and plot the results into a graph (for example from one to twenty readers) – use sufficient hardware (at least 8 cores – total number of threads shouldn't be larger than physical cores) – you can use our server called Ritchie ssh username@ritchie.ciirc.cvut.cz (KOS password)
  7. Commit the graph and code changes to your tutor (then into upload system). The graph should look roughly like this:

pthread rwlocks

The rwlock is part of pthread library. You could be interested in:

Userspace RCU

The liburcu should work on Linux, Cygwin and MacOS X. You can obtain liburcu from distribution repository or compile yourself. If you want to use your own machine, I would recommend you to use library from distribution repository (`sudo apt install liburcu-dev`). In order to compile and use the library do the following:

Examples how to use liburcu are available also on github: https://github.com/urcu/userspace-rcu/tree/master/doc/examples/list

Ritchie

If you want to share your session with me, type tmux-share joel.

Supplementary materials

Article about threads and various types of locks

Article about Userspace RCU library

User-Level Implementations of Read-Copy Update