/
index.html
1284 lines (1182 loc) · 48.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<!-- Font Awesome CSS -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<!-- highlight.js -->
<link rel="stylesheet" href="highlight.default.css">
<script src="highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<title>POPL'19 Project Page</title>
<style type="text/css">
header {
padding: .75rem;
}
header .logos a {
display: inline-block;
}
header .logos a:hover {
opacity: .7;
transform: scale(1.05, 1.05);
}
</style>
</head>
<body>
<header>
<div class="container clearfix">
<h1 class="display-4 text-muted text-left mt-3 float-left">
POPL'19 Project Page
</h1>
<h1 class="display-4 text-muted text-right mt-3 float-right logos">
<a target="new" href="https://www.tcs.cs.tu-bs.de/index.html">
<img src="https://www.tcs.cs.tu-bs.de/images/logo_tcs.png" alt="Institute of Theoretical Computer Science" style="height: .85em; margin-top: -.15em;">
</a>
</h1>
</div>
</header>
<div class="container clearfix">
<!-- ********************************************************************************** -->
<!-- ************************************** PAPER ************************************* -->
<!-- ********************************************************************************** -->
<div class="jumbotron">
<img src="artifacts_evaluated_reusable.png" class="ml-4 mr-3" style="max-height: 9rem; float: right;">
<h1 style="font-size: 2.75rem;">
Decoupling Lock-Free Data Structures from Memory Reclamation for Static Analysis
</h1>
<h2>
<small>
<a href="https://www.tcs.cs.tu-bs.de/group/meyer/home.html">Roland Meyer</a>
and
<a href="https://www.tcs.cs.tu-bs.de/group/wolff/home.html">Sebastian Wolff</a>,
TU Braunschweig, Germany
</small>
</h2>
<h3>
<small>
Presented at <a href="https://popl19.sigplan.org/home">POPL'19</a>.
</small>
</h3>
<!-- <p class="lead">Accepted for <a href="https://popl19.sigplan.org/home">POPL'19</a>.</p> -->
<p class="lead text-justify mb-2">
<strong>Abstract.</strong>
Verification of concurrent data structures is one of the most challenging tasks in software verification.
The topic has received considerable attention over the course of the last decade.
Nevertheless, human-driven techniques remain cumbersome and notoriously difficult while automated approaches suffer from limited applicability.
The main obstacle for automation is the complexity of concurrent data structures.
This is particularly true in the absence of garbage collection.
The intricacy of lock-free memory management paired with the complexity of concurrent data structures makes automated verification prohibitive.
<br>
In this work we present a method for verifying concurrent data structures and their memory management separately.
We suggest two simpler verification tasks that
imply the correctness of the data structure.
The first task establishes an over-approximation of the reclamation behavior of the memory management.
The second task exploits this over-approximation to verify the data structure without the need to consider the implementation of the memory management itself.
To make the resulting verification tasks tractable for automated techniques, we establish a second result.
We show that a verification tool needs to consider only executions where a single memory location is reused.
We implemented our approach and were able to verify linearizability of Michael&Scott's queue and the DGLM queue for both hazard pointers and epoch-based reclamation.
To the best of our knowledge, we are the first to verify such implementations fully automatically.
</p>
<div class="text-right mt-3">
<a href="http://www.tcs.cs.tu-bs.de/group/wolff/doc/popl19/popl19-MeyerWolff.pdf" class="btn btn-primary text-right">
<i class="far fa-file-pdf"></i>
Paper
</a>
<a href="http://www.tcs.cs.tu-bs.de/group/wolff/doc/popl19/popl19-MeyerWolff-slides.pdf" class="btn btn-primary text-right">
<i class="far fa-file-pdf"></i>
Slides
</a>
<a href="https://arxiv.org/abs/1810.10807" class="btn btn-primary text-right">
<i class="far fa-file-pdf"></i>
Technical Report
</a>
<a href="https://doi.org/10.1145/3290371" class="btn btn-primary text-right">
<i class="far fa-file-pdf"></i>
DOI
</a>
<div class="dropdown" style="display: inline-block;">
<a class="btn btn-primary dropdown-toggle" href="#" role="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-code"></i>
Source Code
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="https://github.com/Wolff09/TMRexp/releases/tag/POPL19-chkds">Verifying lock-free data structures</a>
<a class="dropdown-item" href="https://github.com/Wolff09/TMRexp/releases/tag/POPL19-chksmr">Verifying memory reclamation</a>
</div>
</div>
<a href="https://www.tcs.cs.tu-bs.de/documents/POPL19Artifact.ova" class="btn btn-primary text-right">
<i class="fas fa-hdd"></i>
Virtual Machine
</a>
</div>
<hr class="my-4">
<p>
CCS Concepts:
<strong>• Theory of computation → Data structures design and analysis; Program verification;</strong> Shared memory algorithms; Program specifications; Program analysis;
</p>
<p class="mb-4">
Additional Key Words and Phrases:
static analysis, lock-free data structures, verification, linearizability, safe memory reclamation, memory management
</p>
<p class="mb-0">
<b>ACM Reference Format:</b><br>
Roland Meyer and Sebastian Wolff. 2019. Decoupling Lock-Free Data Structures from Memory Reclamation for Static Analysis. <i>Proc. ACM Program. Lang.</i> 3, POPL, Article 58 (January 2019), 31 pages. <a href="https://doi.org/10. 1145/3290371">https://doi.org/10.1145/3290371</a>
</p>
</div>
<br>
<!-- ********************************************************************************** -->
<!-- ************************************* TOOLS ************************************** -->
<!-- ********************************************************************************** -->
<div class="mt-4">
<h1>Tool Overview</h1>
<p>
Our paper presents an analysis for verifying lock-free data structures that use safe memory reclamation (SMR) techniques.
We follow a compositional approach which factors out the verification of the SMR implementation.
Consequently, we have two distinct tools for:
</p>
<ul>
<li><kbd>chkds</kbd> verifying lock-free data structures relative to an SMR specification, and</li>
<li><kbd>chksmr</kbd> verifying an SMR implementation against an SMR specification.</li>
</ul>
<p>
The SMR specification is given in form of an observer automata (hard coded into our tools).
For data structures, we verify liniearizability (we assume that programs are annotated with linearization points).
</p>
<p>
We submitted our tool to the <a href="https://popl19.sigplan.org/track/POPL-2019-Artifact-Evaluation">POPL'19 artifact evaluation</a> where it received the <i>Artifact Evaluated -- Reusable</i> badge.
</p>
<p>
In the this page we discuss how to reproduce our experiments.
Therefore, we walk through the installation, compilation, and benchmarking.
In the end, we briefly link the concepts and techniques from the paper to our implementation.
</p>
<h4>Tool Limitation</h4>
<p>
Our tools do not come with a front end (aka parser).
To analyse programs not included in our benchmarks, one has to compile an appropriate binary first.
If desired, consider the provided benchmark implementations.
For example, consider:
<ul>
<li><kbd>chkds</kbd> <code>TMRexp-POPL19/test/HP/MichaelScottQueue.cpp</code>, or</li>
<li><kbd>chksmr</kbd> <code>TMRexp-POPL19/test/HP/Stack.cpp</code>.</li>
</ul>
Benchmark program code is constructed in those files using intuitive shortcuts (a complete list can be found in <code>TMRexp-POPL19/src/prog.hpp</code>, lines 655f).
</p>
</div>
<br>
<!-- ********************************************************************************** -->
<!-- ************************************* INSTALL ************************************ -->
<!-- ********************************************************************************** -->
<div class="mt-4">
<h1>Installation and Compilation</h1>
<p>This section describes how to setup your system to repeat the benchmarks from the paper.</p>
<!-- Quick Start -->
<div class="alert alert-info container">
<strong>Quick Start.</strong>
Download the Virtual Machine Snapshot (created with <a href="https://www.virtualbox.org">Virtual Box</a>, credentials in <code>~/Desktop/pw.txt</code>).
The artifact is located at <code>~/popl19artifact/</code>.
The folder <code>~/popl19artifact/Binaries</code> contains executables corresponding to the benchmarks from the paper.
If you choose this option you can skip the remainder of this section.
</div>
<!-- Slow Start -->
<h4>Download</h4>
<p>
The source code can be downloaded from GitHub here:
<ul>
<li>
<kbd>chkds</kbd>
<a href="https://github.com/Wolff09/TMRexp/releases/tag/POPL19-chkds">
GitHub release with tag <code>POPL19-chkds</code>
</a>
</li>
<li>
<kbd>chksmr</kbd>
<a href="https://github.com/Wolff09/TMRexp/releases/tag/POPL19-chksmr">
GitHub release with tag <code>POPL19-chksmr</code>
</a>
</li>
</ul>
<!-- <br>
<a href="https://github.com/Wolff09/TMRexp/releases/tag/POPL19-chkds" class="btn btn-light btn-sm">
<i class="fas fa-code"></i>
Data Structure Verification (release with tag <code>POPL19-chkds</code>)
</a>
<a href="https://github.com/Wolff09/TMRexp/releases/tag/POPL19-chksmr" class="btn btn-light btn-sm">
<i class="fas fa-code"></i>
SMR Verification (release with tag <code>POPL19-chksmr</code>)
</a> -->
</p>
<p>
For a unified description of the installation/compilation for both tools, we assume that unzipping yields a folder named <code>TMRexp-POPL19</code>.
</p>
<h4>System Requirements</h4>
<p>
To compile this project you need <strong>CMake</strong>, a <strong>C++17</strong> compatible compiler, and <strong>Boost multi_array</strong>.
Compilation was tested with Apple LLVM v.9.1.0, Apple LLVM v.10.0.0, Clang v.5.0, and Clang v.6.0.
</p>
<h4>Compilation</h4>
<p>
To build the project, simply type make in the root directory of the downloaded sources.
</p>
<pre class="bg-light"><code>
cd path/to/TMRexp-POPL19
make
</code></pre>
<p>This creates a folder <code>build/bin</code> containing all executables.</p>
<p>Alternatively, you can do the following (for example, to specify the compiler to be used):</p>
<pre class="bg-light"><code>
mkdir build
cd build
cmake .. -DCMAKE_CXX_COMPILER=/path/to/CXX-compiler
make
</code></pre>
<p>
Again, folder <code>build/bin</code> contains all executables.
</p>
</div>
<br>
<!-- ********************************************************************************** -->
<!-- ********************************** BENCHMARKING ********************************** -->
<!-- ********************************************************************************** -->
<div class="mt-4">
<h1>Benchmarking <kbd>chkds</kbd></h1>
<p>
We describe how to repeat the benchmarks for verifying lock-free data structures relative to an SMR implementation from the paper.
</p>
<!-- Quick Start -->
<div class="alert alert-info container">
<strong>Quick Start.</strong>
Using the VM from above, execute <code>~/popl19artifact/Binaries/<Program>_<SMR></code> to run the benchmark for <code>Program</code> using <code>SMR</code>.
When compiling on your own, execute <code>TMRexp-POPL19/build/bin/<Program>_<SMR></code> (for the DGLM Queue see the discussion below).
</div>
<!-- Slow Start -->
<h4>Benchmark Programs</h4>
<p>
We evaluated our tool on a <i>Coarse Stack</i>, a <i>Coarse Queue</i>, <i>Treiber's Stack</i>, <i>Michael&Scott's Queue</i>, and the <i>DGLM queue</i> using <i>no SMR (<code>N</code>)</i>, <i>No Reclamation/Garbage Collection (<code>G</code>)</i>, <i>Hazard Pointers (<code>H</code>)</i>, and <i>Epoch-Based Reclamation (<code>E</code>)</i>.
C-style pseudo code is given in the following.
We mark lines that are required only for a specific SMR by the aforementioned letters <code>N</code>, <code>G</code>, <code>H</code>, and <code>E</code>.
</p>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-CS-tab" data-toggle="tab" href="#nav-CS" role="tab" aria-controls="nav-CS" aria-selected="true">Coarse Stack</a>
<a class="nav-item nav-link" id="nav-CQ-tab" data-toggle="tab" href="#nav-CQ" role="tab" aria-controls="nav-CQ" aria-selected="false">Coarse Queue</a>
<a class="nav-item nav-link" id="nav-TS-tab" data-toggle="tab" href="#nav-TS" role="tab" aria-controls="nav-TS" aria-selected="false">Treiber's Stack</a>
<a class="nav-item nav-link" id="nav-OTS-tab" data-toggle="tab" href="#nav-OTS" role="tab" aria-controls="nav-OTS" aria-selected="false">Opt. Treiber's Stack</a>
<a class="nav-item nav-link" id="nav-MS-tab" data-toggle="tab" href="#nav-MS" role="tab" aria-controls="nav-MS" aria-selected="false">Michael&Scott's Queue</a>
<a class="nav-item nav-link" id="nav-DGLM-tab" data-toggle="tab" href="#nav-DGLM" role="tab" aria-controls="nav-DGLM" aria-selected="false">DGLM Queue</a>
</div>
</nav>
<div class="tab-content bg-light" id="nav-tabContent">
<div class="tab-pane show active" id="nav-CS" role="tabpanel" aria-labelledby="nav-CS-tab">
<pre><code>
// binary name: CoarseStack_GC, CoarseStack_NoSMR
struct Node {
data_t data;
Node* next;
};
shared Node* ToS;
atomic init() {
ToS = NULL;
}
void push(data_t input) {
Node* node = new Node();
node->data = input;
atomic {
node->next = ToS;
ToS = node;
}
}
data_t pop() {
atomic {
Node* top = ToS;
if (top == NULL) return EMPTY;
data_t output = top->data;
ToS = Tos->next;
<i> <span class="text-danger">GN</span> retire(top);</i>
return output;
}
}
</code></pre>
</div>
<div class="tab-pane" id="nav-CQ" role="tabpanel" aria-labelledby="nav-CQ-tab">
<pre><code>
// binary name: CoarseQueue_GC, CoarseQueue_NoSMR
struct Node {
data_t data;
Node* next;
};
shared Node* Head, Tail;
atomic init() {
Head = new Node();
Head->next = NULL;
Tail = Head;
}
void enqueue(data_t input) {
Node* node = new Node();
node->data = input;
node->next = NULL;
atomic {
Tail->next = node;
Tail = node;
}
}
data_t dequeue() {
atomic {
Node* head = Head;
Node* next = head->next;
if (next == NULL) return EMPTY;
data_t output = next->data;
Head = next;
<i> <span class="text-danger">GN</span> retire(head);</i>
return output;
}
}
</code></pre>
</div>
<div class="tab-pane" id="nav-TS" role="tabpanel" aria-labelledby="nav-TS-tab">
<pre><code>
// binary name: TreibersStack_GC, TreibersStack_EBR, TreibersStack_HP
struct Node {
data_t data;
Node* next;
};
shared Node* ToS;
atomic init() {
ToS = NULL;
}
void push(data_t input) {
<i> <span class="text-danger">E</span> leaveQ();</i>
Node* node = new Node();
node->data = input;
while (true) {
Node* top = ToS;
<i> <span class="text-danger">H</span> protect(top, 0);</i>
<i> <span class="text-danger">H</span> if (top != ToS) continue;</i>
node->next = top;
if (CAS(&ToS, top, node))
break
}
<i> <span class="text-danger">H</span> unprotect(0);</i>
<i> <span class="text-danger">E</span> enterQ();</i>
}
data_t pop() {
<i> <span class="text-danger">E</span> leaveQ();</i>
while (true) {
Node* top = ToS;
if (top == NULL) return EMPTY;
<i> <span class="text-danger">H</span> protect(top, 0);</i>
<i> <span class="text-danger">H</span> if (top != ToS) continue;</i>
Node* next = top->next;
if (CAS(&ToS, top, next)) {
data_t output = top->data;
<i> <span class="text-danger">HEG</span> retire(top);</i>
<i> <span class="text-danger">H</span> unprotect(0);</i>
<i> <span class="text-danger">E</span> enterQ();</i>
return output;
}
}
}
</code></pre>
</div>
<div class="tab-pane" id="nav-OTS" role="tabpanel" aria-labelledby="nav-OTS-tab">
<pre><code>
// binary name: OptTreibersStack_HP
struct Node {
data_t data;
Node* next;
};
shared Node* ToS;
atomic init() {
ToS = NULL;
}
void push(data_t input) {
Node* node = new Node();
node->data = input;
while (true) {
Node* top = ToS;
node->next = top;
if (CAS(&ToS, top, node))
break
}
}
data_t pop() {
while (true) {
Node* top = ToS;
if (top == NULL) return EMPTY;
<i> <span class="text-danger">H</span> protect(top, 0);</i>
<i> <span class="text-danger">H</span> if (top != ToS) continue;</i>
Node* next = top->next;
if (CAS(&ToS, top, next)) {
data_t output = top->data;
<i> <span class="text-danger">H</span> retire(top);</i>
<i> <span class="text-danger">H</span> unprotect(0);</i>
return output;
}
}
}
</code></pre>
</div>
<div class="tab-pane" id="nav-MS" role="tabpanel" aria-labelledby="nav-MS-tab">
<pre><code>
// binary name: MichaelScottQueue_GC, MichaelScottQueue_EBR, MichaelScottQueue_HP
struct Node {
data_t data;
Node* next;
};
shared Node* Head, Tail;
atomic init() {
Head = new Node();
Head->next = NULL;
Tail = Head;
}
void enqueue(data_t input) {
<i> <span class="text-danger">E</span> leaveQ;</i>
Node* node = new Node();
node->data = input;
node->next = NULL;
while (true) {
Node* tail = Tail;
<i> <span class="text-danger">H</span> protect(tail, 0);</i>
<i> <span class="text-danger">H</span> if (tail != Tail) continue;</i>
Node* next = tail->next;
if (tail != Tail) continue;
if (next != NULL) {
CAS(&Tail, tail, next);
continue;
}
if (CAS(&tail->next, next, node))
break
}
CAS(&Tail, tail, node);
<i> <span class="text-danger">E</span> enterQ;</i>
<i> <span class="text-danger">H</span> unprotect(0);</i>
}
data_t dequeue() {
<i> <span class="text-danger">E</span> leaveQ;</i>
while (true) {
Node* head = Head;
<i> <span class="text-danger">H</span> protect(head, 0);</i>
<i> <span class="text-danger">H</span> if (head != Head) continue;</i>
Node* tail = Tail;
Node* next = head->next;
<i> <span class="text-danger">H</span> protect(next, 1);</i>
if (head != Head) continue;
if (next == NULL) return EMPTY;
if (head == tail) {
CAS(&Tail, tail, next);
continue;
} else {
data_t output = next->data;
if (CAS(&Head, head, next)) {
<i> <span class="text-danger">HEG</span> retire(head);</i>
<i> <span class="text-danger">E</span> enterQ;</i>
<i> <span class="text-danger">H</span> unprotect(0);</i>
<i> <span class="text-danger">H</span> unprotect(1);</i>
return output;
}
}
}
}
</code></pre>
</div>
<div class="tab-pane" id="nav-DGLM" role="tabpanel" aria-labelledby="nav-DGLM-tab">
<pre><code>
// binary name: DGLMQueue_GC, DGLMQueue_EBR, DGLMQueue_HP
struct Node {
data_t data;
Node* next;
};
shared Node* Head, Tail;
atomic init() {
Head = new Node();
Head->next = NULL;
Tail = Head;
}
void enqueue(data_t input) {
<i> <span class="text-danger">E</span> leaveQ;</i>
Node* node = new Node();
node->data = input;
node->next = NULL;
while (true) {
Node* tail = Tail;
<i> <span class="text-danger">H</span> protect(tail, 0);</i>
<i> <span class="text-danger">H</span> if (tail != Tail) continue;</i>
Node* next = tail->next;
if (tail != Tail) continue;
if (next != NULL) {
CAS(&Tail, tail, next);
continue;
}
if (CAS(&tail->next, next, node))
break
}
CAS(&Tail, tail,node);
<i> <span class="text-danger">H</span> unprotect(0);</i>
<i> <span class="text-danger">E</span> enterQ;</i>
}
data_t dequeue() {
<i> <span class="text-danger">E</span> leaveQ;</i>
while (true) {
Node* head = Head;
<i> <span class="text-danger">H</span> protect(head, 0);</i>
<i> <span class="text-danger">H</span> if (head != Head) continue;</i>
Node* next = head->next;
<i> <span class="text-danger">H</span> protect(next, 1);</i>
if (head != Head) continue;
if (next == NULL) return EMPTY;
data_t output = next->data;
if (CAS(&Head, head, next)) {
Node* tail = Tail;
if (head == tail) {
CAS(Tail, tail, next);
}
<i> <span class="text-danger">HEG</span> retire(head);</i>
<i> <span class="text-danger">H</span> unprotect(0);</i>
<i> <span class="text-danger">H</span> unprotect(1);</i>
<i> <span class="text-danger">E</span> enterQ;</i>
return output;
}
}
}
</code></pre>
</div>
</div>
<h4>Running Benchmarks</h4>
<p>
To run the benchmarks got to the <code>build/bin/</code> folder and execute the corresponding binary.
The naming scheme is <code><DS>_<SMR></code> where <code><DS></code> is the name of the benchmark program and <code><SMR></code> is the reclamation scheme.
</p>
<p>
For example, to benchmark the running example from the paper, Michael&Scott's Queue using Hazard Pointers (HP), you have to do the following:
</p>
<pre class="bg-light"><code>
cd path/to/TMRexp-POPL19/build/bin
./MichaelScottQueue_HP
</code></pre>
<h4>The DGLM Queue</h4>
<p>
As stated in the paper, the implemented shape abstraction requires hints to verify the DGLM Queue.
To enable/disable hinting you have to set the corresponding flag in <code>src/config.hpp</code> and recompile the tool.
More precisely, you have to change line 22 from
</p>
<pre><code>
#define DGLM_HINT false
</code></pre>
<p>
to
</p>
<pre><code>
#define DGLM_HINT true
</code></pre>
<p>
Beware: using <code>DGLM_HINT=true</code> with any benchmark other than the DGLM Queue exhibits undefined behavior!
</p>
<p>
For users of the VM image: the folder <code>~/popl19artifact/Binaries/</code> already contains the properly compiled binaries.
The binaries where compiled from <code>~/popl19artifact/chkds/</code> and <code>~/popl19artifact/chkds-DGLM/</code> for all benchmarks except the DGLM Queue and the DGLM Queue, respectively.
</p>
<h4>Expected Benchmarks Results</h4>
<p>
As reported in the paper, running the benchmarks on an Intel Xeon X5650@2.67GHz with Ubuntu 16.04 and using Clang version 5.0 we expect the following running times and verification results.
</p>
<table class="table">
<thead>
<tr>
<th scope="col">Program</th>
<th scope="col">SMR</th>
<th class="text-right" scope="col">Time Verif.</th>
<th class="text-right" scope="col">States</th>
<th class="text-right" scope="col">ABAs</th>
<th class="text-right" scope="col">Time ABA</th>
<th class="text-center" scope="col">Linearizable</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" rowspan="2">Coarse Stack</th>
<td>GC</td>
<td class="text-right">0.44s</td>
<td class="text-right">300</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<td>None</td>
<td class="text-right">0.5s</td>
<td class="text-right">300</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<th scope="row" rowspan="2">Coarse Queue</th>
<td>GC</td>
<td class="text-right">1.7s</td>
<td class="text-right">300</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<td>None</td>
<td class="text-right">1.7s</td>
<td class="text-right">300</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<th scope="row" rowspan="3">Treiber's Stack</th>
<td>GC</td>
<td class="text-right">3.2s</td>
<td class="text-right">806</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<td>EBR</td>
<td class="text-right">16s</td>
<td class="text-right">1822</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<td>HP</td>
<td class="text-right">19s</td>
<td class="text-right">2606</td>
<td class="text-right">186</td>
<td class="text-right">0.06s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<th scope="row">Opt. Treiber's Stack</th>
<td>HP</td>
<td class="text-right">0.8s</td>
<td class="text-right">-</td>
<td class="text-right">-</td>
<td class="text-right">-</td>
<td class="text-center">no<sup>*</sup></td>
</tr>
<tr>
<th scope="row" rowspan="3">Michael&Scott's Queue</th>
<td>GC</td>
<td class="text-right">414s</td>
<td class="text-right">2202</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<td>EBR</td>
<td class="text-right">2630s</td>
<td class="text-right">7613</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<td>HP</td>
<td class="text-right">7075s</td>
<td class="text-right">19028</td>
<td class="text-right">536</td>
<td class="text-right">0.9s</td>
<td class="text-center">yes</td>
</tr>
<tr>
<th scope="row" rowspan="3">DGLM Queue</th>
<td>GC</td>
<td class="text-right">714s</td>
<td class="text-right">9934</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes<sup>**</sup></td>
</tr>
<tr>
<td>EBR</td>
<td class="text-right">3754s</td>
<td class="text-right">27132</td>
<td class="text-right">0</td>
<td class="text-right">0s</td>
<td class="text-center">yes<sup>**</sup></td>
</tr>
<tr>
<td>HP</td>
<td class="text-right">7010s</td>
<td class="text-right">41753</td>
<td class="text-right">2824</td>
<td class="text-right">26s</td>
<td class="text-center">yes<sup>**</sup></td>
</tr>
</tbody>
</table>
<p>
<sup>*</sup> Pointer Race due to an ABA in <code>push</code> makes the verification fail.
<br>
<sup>**</sup> Imprecision in the heap abstraction required hinting that <code>Head</code> cannot overtake <code>Tail</code> by more than one node.
</p>
</div>
<br>
<!-- ********************************************************************************** -->
<!-- ********************************** BENCHMARKING ********************************** -->
<!-- ********************************************************************************** -->
<div class="mt-4">
<h1>Benchmarking <kbd>chksmr</kbd></h1>
<p>
We describe how to repeat the benchmarks for verifying SMR implementations from the paper.
</p>
<!-- Quick Start -->
<div class="alert alert-info container">
<strong>Quick Start.</strong>
Using the VM from above, execute <code>~/popl19artifact/Binaries/<SMR></code> to run the benchmark for the SMR implementation <code>SMR</code>.
When compiling on your own, execute <code>TMRexp-POPL19/build/bin/<SMR></code>.
</div>
<!-- Slow Start -->
<h4>Benchmark Programs</h4>
<p>
We evaluated our tool on an <i>Hazard Pointer (HP)</i> and an <i>Epoch-based Reclamation (EBR)</i> implementation both of which support dynamic joining/parting of threads.
C-style pseudo code is given in the following.
</p>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-HP-tab" data-toggle="tab" href="#nav-HP" role="tab" aria-controls="nav-HP" aria-selected="true">Hazard Pointers</a>
<a class="nav-item nav-link" id="nav-EBR-tab" data-toggle="tab" href="#nav-EBR" role="tab" aria-controls="nav-EBR" aria-selected="false">Epoch-based Reclamation</a>
</div>
</nav>
<div class="tab-content bg-light" id="nav-tabContent">
<div class="tab-pane show active" id="nav-HP" role="tabpanel" aria-labelledby="nav-HP-tab">
<pre><code>
// binary name: HPimpl
struct HPRec {
HPRec* next;
void* hp0;
void* hp1;
};
shared HPRec* Records;
threadlocal HPRec* myRec;
threadlocal List<void*> retiredList;
atomic init() {
Records = NULL;
}
void join() {
myRec = new HPRec();
while (true) {
HPRec* rec = Records;
myRec->next = rec;
if (CAS(Records, rec, myRec)) {
break;
}
}
myRec->hp0 = NULL;
myRec->hp1 = NULL;
}
void part() {
unprotect(0);
unprotect(1);
}
void protect0(void* ptr) {
myRec->hp0 = ptr;
}
void protect1(void* ptr) {
myRec->hp1 = ptr;
}
void unprotect0() {
myRec->hp0 = NULL;
}
void unprotect1() {
myRec->hp1 = NULL;
}
void retire(void* ptr) {
if (ptr != NULL) {
retiredList.add(ptr);
}
if (*) {
reclaim();
}
}
void reclaim() {
List<void*> protectedList;
HPRec* cur = Records;
while (cur != NULL) {
void* hp0 = cur->hp0;
void* hp1 = cur->hp1;
protectedList.add(hp0);
protectedList.add(hp1);
cur = cur->next();
}
List<void*> freeList = retiredList.copy();
freeList = freeList.remove_all(protectedList);
retiredList = retiredList.remove_all(freeList);
free_all(freeList);
}
void free_all(List<void*> list) {
for (void* ptr : list) {
free(ptr);
}
}
</code></pre>
</div>
<div class="tab-pane" id="nav-EBR" role="tabpanel" aria-labelledby="nav-EBR-tab">
<pre><code>
// binary name: EBRimpl
enum epoch_t { 0, 1, 2 };
struct EBRRec {
EBRRec* next;
epoch_t epoch;
};
shared EBRRec* Records;
shared epoch_t Epoch;
threadlocal EBRRec* myRec;
threadlocal List<void*> bag0;
threadlocal List<void*> bag1;
threadlocal List<void*> bag2;
atomic init() {
Records = NULL;
Epoch = 0;
}
void join() {
myRec = new EBRRec();
while (true) {
EBRRec* rec = Records;
myRec->next = rec;
if (CAS(Records, rec, myRec)) {
break;
}
}
myEpoch = Epoch;
myRec->epoch = myEpoch;
}
void part() {
}
void enterQ() {
}
void leaveQ() {
if (*) {
if (myEpoch != Epoch) {
free_all(bag2);
bag2 = bag1;
bag1 = bag0;
bag0 = List<void*>::empty();
myEpoch = Epoch;
myRec->epoch = myEpoch;
}
EBRrec* cur = Records;
while (cur != NULL) {
if (epoch != cur->epoch) {
break;
}
cur = cur->next;
}
CAS(Epoch, epoch, (epoch + 1) % 3);
}
}
void retire(void* ptr) {
bag0.add(ptr);
}
void free_all(List<void*> list) {
for (void* ptr : list) {
free(ptr);
}
}
</code></pre>
</div>
</div>
<h4>Running Benchmarks</h4>
<p>
To run the benchmarks got to the <code>build/bin/</code> folder and execute the corresponding binary.
The naming scheme is <code><SMR>_<Info></code> where <code><SMR></code> is the (abbreviated) name of the benchmark program and <code><Info></code> is a description of the implementation (we have various implementations for each class).
</p>
<p>
For example, to benchmark the running example from the paper, the Hazard Pointer implementation, you have to do the following:
</p>
<pre class="bg-light"><code>
cd path/to/TMRexp-POPL19/build/bin
./HPimpl
</code></pre>
<h4>Expected Benchmarks Results</h4>
<p>
As reported in the paper, running the benchmarks on an Intel Xeon X5650@2.67GHz with Ubuntu 16.04 and using Clang version 5.0 we expect the following running times and verification results.
</p>
<table class="table">
<thead>
<tr>
<th scope="col">Program</th>
<th scope="col">Observer</th>
<th class="text-right" scope="col">Time</th>