> For the complete documentation index, see [llms.txt](https://sliu583.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sliu583.gitbook.io/blog/persistence/index/hardware/an-empirical-guide-to-the-behavior-and-use-of-scalable-persistent-memory.md).

# An Empirical Guide to the Behavior and Use of Scalable Persistent Memory

### Presentation&#x20;

* Optane DIMMs&#x20;
  * Not just slow dense DRAM&#x20;
  * Slower media&#x20;
    * More complex architecture&#x20;
      * Second-order performance anomalies&#x20;
        * Fundamentally different&#x20;
* Outline&#x20;
  * Background&#x20;
  * Basics: Optane DIMM performance&#x20;
  * Lessons: Optane DIMM best practices&#x20;
  * Conclusion&#x20;

#### Background: Optane in the machine&#x20;

* iMC: integrated memory controller&#x20;
* use optane&#x20;
  * *Memory mode* : use Optane to expand main memory capacity without persistence&#x20;
    * Combine Optane DIMM with a conventional DRAM DIMM on the same memory channel that serves as a direct-mapped cache for the NVDIMM&#x20;
  * *App Direct mode* : provides persistence and does not use a DRAM cache&#x20;

![Focus on the right ](/files/-MjHjEtOMVee3NYC2C2L)

* Optane controller: merging 4 cache lines into 256B block and issuing that block to media&#x20;
  * Buffer: merging&#x20;
* AIT: address interaction table&#x20;
  * Resides in optane media, but also cache on device dram&#x20;
* ADR:&#x20;
  * If power failure, then we have enough stand-up power to flush the write pending queue to media&#x20;
    * The ADR domain does not include the processor caches, so stores are only persistent once they reach WPQs&#x20;
  * WPQ: write pending queue&#x20;
  * The iMC communicates wih the Optane DIMM using the DDR-T interface in cache-line (64-byte) granularity
    * Has to do with the physical features of how to data is laid out&#x20;

![ADR ](/files/-MjHjlJ5IbaHbXwBvFGM)

![](/files/-MjHkCuevfTmw9SkKI09)

* First 4K: optane DIMM 1
* Next 4K: optane DIMM 4&#x20;
* Touch all six optane DIMM&#x20;

#### Basics: our approach&#x20;

![Microbenchmark ](/files/-MjHkbIMcxX_tcl7o-ME)

![](/files/-MjHl1xV8wtqaZu55U7c)

* Sequentially: no access amplification&#x20;
  * In contrast, random, 3x as small&#x20;
* Write&#x20;
  * Is acknowledged as soon as it hits the on socket integrated memory controller&#x20;
    * Not measure all the way to media&#x20;
      * Not possible to measure this?&#x20;
    * Writing to the cache + flushing it out&#x20;
      * Write to cache is the same for both cases&#x20;
      * Flush

![](/files/-MjHlSnpU9rYGJ3cW_yJ)

* DRAM
  * More cores, performance goes up&#x20;
* NI: non-interleave&#x20;
  * Read from single DIMM&#x20;
  * Bandwidth low&#x20;
  * Speculate: slow media, contentions, extra delay because of this contention&#x20;
* Interleave
  * Write: saturate bandwidth and contention is growing worse&#x20;
    * 3 cores and slow down&#x20;
* Use all optane dimms, interleave reads (scale well), efficiently
* Write (max out) constant with respect to thread counts&#x20;

![](/files/-MjHlriPLO2vizTQjtin)

* Using the block size efficiently&#x20;

![](/files/-MjHlyg8WSScyDi9bfH2)

* Read: Peak bandwidth at 512B, but valley at 4K (weird contention)
  * File system use this 4KB size&#x20;

#### Lessons: what are Optane best practices?&#x20;

* Avoid small random accesses&#x20;
* Use ntstores for large writes&#x20;
* Limit threads accessing one NVDIMM
* Avoid mixed and multi-threaded NUMA accesses

**Lesson 1: avoid small random accesses** &#x20;

![](/files/-MjHmSUE2BsNjcZRBWEs)

* Small accesses: smaller than 256B, lose bandwidth&#x20;

![](/files/-MjHmbbp7QIj2MORrjjP)

* Vary the working set size&#x20;
  * How large this on-device buffer is? About 16K&#x20;

![](/files/-MjHmtvKkoe5uPVbIDCG)

**Lesson 2: Use ntstores for large writes**&#x20;

![](/files/-MjHnAiDnyTClgNmAmcf)

* ntstore (non-temporal store): bypass the cache hierarchy and issue directly to the backing DIMM
* store + clwb: doing Aa store and then evicting that cache line or cleaning the cache line using a cache line write back (CLWB)
  * Con: Lost bandwidth&#x20;
  * Preserve the sequential access if all possible&#x20;
  * Doing a read plus a write, using double the bandwidth&#x20;
* store: trickle out from the cache into media &#x20;
  * Con: Lost locality&#x20;
  * Cache is going to evict the cache line when it decides to, not optimize for evicting things in a sequential pattern (i.e. introduce randomness) --> terrible device utilization&#x20;

![](/files/-MjHoIzJN9gmRnzSlylM)

![](/files/-MjHoQTtu_0TKFQP07Zp)

**Lesson #3: Limit threads accessing one NVDIMM**&#x20;

* Contention at Optane Buffer: merging adjacent accesses&#x20;
* Contention at iMC&#x20;

Contention at Optane Buffer&#x20;

![](/files/-MjHqSJbGyMBm2DEjd3G)

* Multiple threads: thrash on this on-device cache&#x20;
  * What would otherwise can be sequential access that can be merged is no longer the case&#x20;
  * All threads are putting their own writes, lose the opportunity to merge &#x20;
  * Read&#x20;
    * Spike: max bandwidth&#x20;
    * Add more: thrashing the cache&#x20;

![](/files/-MjHr-5XKmcXar9VOZ-X)

![](/files/-MjHr3DmWsvU_3E9LiQ8)

* Multiple threads - multiple DIMM - clogging the single DIMM (bandwidth falls down)
* Ends up with stall&#x20;

![](/files/-MjHwOOI_LTaSy4TrUtj)

* Exactly interleave size: burst of the accesses (hit the memory controller and the same DIMM)&#x20;

![](/files/-MjHwTXNw0aOgPthRt2J)

**Lesson #4: avoid mixed and multi-threaded NUMA accesses**

![](/files/-MjHwcL6ruUtXuPDnwVO)

![](/files/-MjHwkgzuP-I6RvsScBc)
