191
Listing 11-3 presents both approaches; in this example, we want to increase the first
integer by one.
Listing 11-3. Layout and snapshotting performance
37 struct soa {
38 int a[1000];
39 int b[1000];
40 };
41
42 struct root {
43 soa soa_records;
44 std::pair 45 };
46
47 int main()
48 {
49 try {
50
auto pop = pmem::obj::pool::create("/daxfs/pmpool",
51
"data_oriented", PMEMOBJ_MIN_POOL, 0666);
52
53 auto root = pop.root();
54
55 pmem::obj::transaction::run(pop, [&]{
56
pmem::obj::transaction::snapshot(&root->soa_records);
57
for (int i = 0; i < 1000; i++) {
58
root->soa_records.a[i]++;
59
}
60
61
for (int i = 0; i < 1000; i++) {
62
pmem::obj::transaction::snapshot(
63
&root->aos_records[i].first);
64
root->aos_records[i].first++;
65
}
66 });
67
Chapter 11 Designing Data struCtures for persistent MeMory
Précédent

- 215/457

Suivant