Lesson 4: NUMA

On readings: Recommended background readings are marked with (^) above. Optional historical or fun readings are marked with (*). If you feel confortable with the topic already, you may skip these readings.

Notes

I will cover some core concepts you’ll need to really get the most out of this paper. The slides can be found on Canvas.

NUMA Overview

NUMA policies

Scale-out NUMA

Deduplication and KSM

Deduplication is a general technique used in systems to reduce memory usage. The basic observation (which can be leveraged in many domains) is that applications tend to have duplicate instances of data. When that occurs, instead of maintaining multiple copies, the system can create one copy of the data and store references to that data instead.

We can apply dedup to paging. Here, we’d like to examine all physical pages used on our system, and if we find that there are two (or more) pages that contain the same content, we can merge them into one physical page, and update the two PTEs to point to this one page. We can even do this across processes, and it will often be useful to do so. The Linux kernel has implemented this in the form of kernel same page merging (KSM).

KSM runs as a low-priority background kernel thread (ksmd). Scanning physical pages, merging them, and updating PTEs to reflect the merge.

Think about what would happen if duplicate pages across processes have been turned into a shared page, and then one of those processes goes to try to write its copy. What should the kernel do?

You should also think about this algorithmically. What’s the complexity of a KSM algorithm? Hint: you can identify duplicate pages by hashing their contents and comparing hashes (rather than a byte-by-byte comparison). How do you avoid merging pages that will soon be written to?