206
Let’s analyze whether this approach guarantees data consistency. In the first step,
we copy elements from the original array to a currently unused one, insert the new
element, and persist it to make sure data goes to the persistence domain. The persist
call also ensures that the next operation (updating the current value) is not reordered
before any of the previous stores. Because of this, any interruption before or after issuing
the instruction to update the current field would not corrupt data because the current
variable always points to a valid version.
The memory overhead of using versioning for the insert operation is equal to a size
of the entries array and the current field. In terms of time overhead, we issued only two
persist operations.
Summary
This chapter shows how to design data structures for persistent memory, considering its
characteristics and capabilities. We discuss fragmentation and why it is problematic in
the case of persistent memory. We also present a few different methods of guaranteeing
data consistency; using transactions is the simplest and least error-prone method.
Other approaches, such as copy-on-write or versioning, can perform better, but they are
significantly more difficult to implement correctly.
Open Access This chapter is licensed under the terms of the Creative
Commons Attribution 4.0 International License (http://creativecommons.
org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and
reproduction in any medium or format, as long as you give appropriate credit to the
original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s
Creative Commons license, unless indicated otherwise in a credit line to the material. If
material is not included in the chapter’s Creative Commons license and your intended
use is not permitted by statutory regulation or exceeds the permitted use, you will need
to obtain permission directly from the copyright holder.
Chapter 11 Designing Data struCtures for persistent MeMory
Let’s analyze whether this approach guarantees data consistency. In the first step,
we copy elements from the original array to a currently unused one, insert the new
element, and persist it to make sure data goes to the persistence domain. The persist
call also ensures that the next operation (updating the current value) is not reordered
before any of the previous stores. Because of this, any interruption before or after issuing
the instruction to update the current field would not corrupt data because the current
variable always points to a valid version.
The memory overhead of using versioning for the insert operation is equal to a size
of the entries array and the current field. In terms of time overhead, we issued only two
persist operations.
Summary
This chapter shows how to design data structures for persistent memory, considering its
characteristics and capabilities. We discuss fragmentation and why it is problematic in
the case of persistent memory. We also present a few different methods of guaranteeing
data consistency; using transactions is the simplest and least error-prone method.
Other approaches, such as copy-on-write or versioning, can perform better, but they are
significantly more difficult to implement correctly.
Open Access This chapter is licensed under the terms of the Creative
Commons Attribution 4.0 International License (http://creativecommons.
org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and
reproduction in any medium or format, as long as you give appropriate credit to the
original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s
Creative Commons license, unless indicated otherwise in a credit line to the material. If
material is not included in the chapter’s Creative Commons license and your intended
use is not permitted by statutory regulation or exceeds the permitted use, you will need
to obtain permission directly from the copyright holder.
Chapter 11 Designing Data struCtures for persistent MeMory
