Unbounded queue
[folly.git] / folly / concurrency / test / UnboundedQueueTest.cpp
1 /*
2  * Copyright 2017 Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <folly/concurrency/UnboundedQueue.h>
18 #include <folly/MPMCQueue.h>
19 #include <folly/ProducerConsumerQueue.h>
20 #include <folly/portability/GTest.h>
21
22 #include <glog/logging.h>
23
24 #include <atomic>
25 #include <thread>
26
27 DEFINE_bool(bench, false, "run benchmark");
28 DEFINE_int32(reps, 10, "number of reps");
29 DEFINE_int32(ops, 1000000, "number of operations per rep");
30
31 template <typename T, bool MayBlock>
32 using USPSC = folly::USPSCQueue<T, MayBlock>;
33
34 template <typename T, bool MayBlock>
35 using UMPSC = folly::UMPSCQueue<T, MayBlock>;
36
37 template <typename T, bool MayBlock>
38 using USPMC = folly::USPMCQueue<T, MayBlock>;
39
40 template <typename T, bool MayBlock>
41 using UMPMC = folly::UMPMCQueue<T, MayBlock>;
42
43 template <template <typename, bool> class Q, bool MayBlock>
44 void basic_test() {
45   Q<int, MayBlock> q;
46   ASSERT_TRUE(q.empty());
47   ASSERT_EQ(q.size(), 0);
48   int v = -1;
49   ASSERT_FALSE(q.try_dequeue(v));
50
51   q.enqueue(1);
52   ASSERT_FALSE(q.empty());
53   ASSERT_EQ(q.size(), 1);
54
55   q.enqueue(2);
56   ASSERT_EQ(q.size(), 2);
57   ASSERT_FALSE(q.empty());
58
59   ASSERT_TRUE(q.try_dequeue(v));
60   ASSERT_EQ(v, 1);
61   ASSERT_FALSE(q.empty());
62   ASSERT_EQ(q.size(), 1);
63
64   ASSERT_TRUE(q.try_dequeue(v));
65   ASSERT_EQ(v, 2);
66   ASSERT_TRUE(q.empty());
67   ASSERT_EQ(q.size(), 0);
68 }
69
70 TEST(UnboundedQueue, basic) {
71   basic_test<USPSC, false>();
72   basic_test<UMPSC, false>();
73   basic_test<USPMC, false>();
74   basic_test<UMPMC, false>();
75   basic_test<USPSC, true>();
76   basic_test<UMPSC, true>();
77   basic_test<USPMC, true>();
78   basic_test<UMPMC, true>();
79 }
80
81 template <template <typename, bool> class Q, bool MayBlock>
82 void timeout_test() {
83   Q<int, MayBlock> q;
84   int v = -1;
85   ASSERT_FALSE(q.try_dequeue_until(
86       v, std::chrono::steady_clock::now() + std::chrono::microseconds(1)));
87   ASSERT_FALSE(q.try_dequeue_for(v, std::chrono::microseconds(1)));
88   q.enqueue(10);
89   ASSERT_TRUE(q.try_dequeue_until(
90       v, std::chrono::steady_clock::now() + std::chrono::microseconds(1)));
91   ASSERT_EQ(v, 10);
92 }
93
94 TEST(UnboundedQueue, timeout) {
95   timeout_test<USPSC, false>();
96   timeout_test<UMPSC, false>();
97   timeout_test<USPMC, false>();
98   timeout_test<UMPMC, false>();
99   timeout_test<USPSC, true>();
100   timeout_test<UMPSC, true>();
101   timeout_test<USPMC, true>();
102   timeout_test<UMPMC, true>();
103 }
104
105 template <typename ProdFunc, typename ConsFunc, typename EndFunc>
106 inline uint64_t run_once(
107     int nprod,
108     int ncons,
109     const ProdFunc& prodFn,
110     const ConsFunc& consFn,
111     const EndFunc& endFn) {
112   std::atomic<bool> start{false};
113   std::atomic<int> ready{0};
114
115   /* producers */
116   std::vector<std::thread> prodThr(nprod);
117   for (int tid = 0; tid < nprod; ++tid) {
118     prodThr[tid] = std::thread([&, tid] {
119       ++ready;
120       while (!start.load()) {
121         /* spin */;
122       }
123       prodFn(tid);
124     });
125   }
126
127   /* consumers */
128   std::vector<std::thread> consThr(ncons);
129   for (int tid = 0; tid < ncons; ++tid) {
130     consThr[tid] = std::thread([&, tid] {
131       ++ready;
132       while (!start.load()) {
133         /* spin */;
134       }
135       consFn(tid);
136     });
137   }
138
139   /* wait for all producers and consumers to be ready */
140   while (ready.load() < (nprod + ncons)) {
141     /* spin */;
142   }
143
144   /* begin time measurement */
145   auto tbegin = std::chrono::steady_clock::now();
146   start.store(true);
147
148   /* wait for completion */
149   for (int i = 0; i < nprod; ++i) {
150     prodThr[i].join();
151   }
152   for (int i = 0; i < ncons; ++i) {
153     consThr[i].join();
154   }
155
156   /* end time measurement */
157   auto tend = std::chrono::steady_clock::now();
158   endFn();
159   return std::chrono::duration_cast<std::chrono::nanoseconds>(tend - tbegin)
160       .count();
161 }
162
163 template <bool SingleProducer, bool SingleConsumer, bool MayBlock>
164 void enq_deq_test(const int nprod, const int ncons) {
165   if (SingleProducer) {
166     ASSERT_EQ(nprod, 1);
167   }
168   if (SingleConsumer) {
169     ASSERT_EQ(ncons, 1);
170   }
171
172   int ops = 1000;
173   folly::UnboundedQueue<int, SingleProducer, SingleConsumer, MayBlock, 4> q;
174   std::atomic<uint64_t> sum(0);
175
176   auto prod = [&](int tid) {
177     for (int i = tid; i < ops; i += nprod) {
178       q.enqueue(i);
179     }
180   };
181
182   auto cons = [&](int tid) {
183     uint64_t mysum = 0;
184     for (int i = tid; i < ops; i += ncons) {
185       int v = -1;
186
187       if ((i % 3) == 0) {
188         while (!q.try_dequeue(v)) {
189           /* keep trying */;
190         }
191       } else if ((i % 3) == 1) {
192         std::chrono::steady_clock::time_point deadline =
193             std::chrono::steady_clock::now() + std::chrono::milliseconds(1);
194         while (!q.try_dequeue_until(v, deadline)) {
195           /* keep trying */;
196         }
197       } else {
198         q.dequeue(v);
199       }
200       if (nprod == 1 && ncons == 1) {
201         ASSERT_EQ(v, i);
202       }
203       mysum += v;
204     }
205     sum.fetch_add(mysum);
206   };
207
208   auto endfn = [&] {
209     uint64_t expected = ops;
210     expected *= ops - 1;
211     expected /= 2;
212     ASSERT_EQ(sum.load(), expected);
213   };
214   run_once(nprod, ncons, prod, cons, endfn);
215 }
216
217 TEST(UnboundedQueue, enq_deq) {
218   /* SPSC */
219   enq_deq_test<true, true, false>(1, 1);
220   enq_deq_test<true, true, true>(1, 1);
221   /* MPSC */
222   enq_deq_test<false, true, false>(1, 1);
223   enq_deq_test<false, true, true>(1, 1);
224   enq_deq_test<false, true, false>(2, 1);
225   enq_deq_test<false, true, true>(2, 1);
226   enq_deq_test<false, true, false>(10, 1);
227   enq_deq_test<false, true, true>(10, 1);
228   /* SPMC */
229   enq_deq_test<true, false, false>(1, 1);
230   enq_deq_test<true, false, true>(1, 1);
231   enq_deq_test<true, false, false>(1, 2);
232   enq_deq_test<true, false, true>(1, 2);
233   enq_deq_test<true, false, false>(1, 10);
234   enq_deq_test<true, false, true>(1, 10);
235   /* MPMC */
236   enq_deq_test<false, false, false>(1, 1);
237   enq_deq_test<false, false, true>(1, 1);
238   enq_deq_test<false, false, false>(2, 1);
239   enq_deq_test<false, false, true>(2, 1);
240   enq_deq_test<false, false, false>(10, 1);
241   enq_deq_test<false, false, true>(10, 1);
242   enq_deq_test<false, false, false>(1, 2);
243   enq_deq_test<false, false, true>(1, 2);
244   enq_deq_test<false, false, false>(1, 10);
245   enq_deq_test<false, false, true>(1, 10);
246   enq_deq_test<false, false, false>(2, 2);
247   enq_deq_test<false, false, true>(2, 2);
248   enq_deq_test<false, false, false>(10, 10);
249   enq_deq_test<false, false, true>(10, 10);
250 }
251
252 template <typename RepFunc>
253 uint64_t runBench(const std::string& name, int ops, const RepFunc& repFn) {
254   int reps = FLAGS_reps;
255   uint64_t min = UINTMAX_MAX;
256   uint64_t max = 0;
257   uint64_t sum = 0;
258
259   repFn(); // sometimes first run is outlier
260   for (int r = 0; r < reps; ++r) {
261     uint64_t dur = repFn();
262     sum += dur;
263     min = std::min(min, dur);
264     max = std::max(max, dur);
265     // if each rep takes too long run at least 3 reps
266     const uint64_t minute = 60000000000UL;
267     if (sum > minute && r >= 2) {
268       reps = r + 1;
269       break;
270     }
271   }
272
273   const std::string unit = " ns";
274   uint64_t avg = sum / reps;
275   uint64_t res = min;
276   std::cout << name;
277   std::cout << "   " << std::setw(4) << max / ops << unit;
278   std::cout << "   " << std::setw(4) << avg / ops << unit;
279   std::cout << "   " << std::setw(4) << res / ops << unit;
280   std::cout << std::endl;
281   return res;
282 }
283
284 template <template <typename, bool> class Q, typename T, int Op>
285 uint64_t bench(const int nprod, const int ncons, const std::string& name) {
286   int ops = FLAGS_ops;
287   auto repFn = [&] {
288     Q<T, Op == 3 || Op == 4 || Op == 5> q;
289     std::atomic<uint64_t> sum(0);
290     auto prod = [&](int tid) {
291       for (int i = tid; i < ops; i += nprod) {
292         q.enqueue(i);
293       }
294     };
295     auto cons = [&](int tid) {
296       std::chrono::steady_clock::time_point deadline =
297           std::chrono::steady_clock::now() + std::chrono::hours(24);
298       uint64_t mysum = 0;
299       for (int i = tid; i < ops; i += ncons) {
300         T v;
301         if (Op == 0 || Op == 3) {
302           while (UNLIKELY(!q.try_dequeue(v))) {
303             /* keep trying */;
304           }
305         } else if (Op == 1 || Op == 4) {
306           while (UNLIKELY(!q.try_dequeue_until(v, deadline))) {
307             /* keep trying */;
308           }
309         } else {
310           ASSERT_TRUE(Op == 2 || Op == 5);
311           q.dequeue(v);
312         }
313         if (nprod == 1 && ncons == 1) {
314           DCHECK_EQ(int(v), i);
315         }
316         mysum += v;
317       }
318       sum.fetch_add(mysum);
319     };
320     auto endfn = [&] {
321       uint64_t expected = ops;
322       expected *= ops - 1;
323       expected /= 2;
324       ASSERT_EQ(sum.load(), expected);
325     };
326     return run_once(nprod, ncons, prod, cons, endfn);
327   };
328   return runBench(name, ops, repFn);
329 }
330
331 /* For performance comparison */
332 template <typename T, size_t capacity>
333 class MPMC {
334   folly::MPMCQueue<T> q_;
335
336  public:
337   MPMC() : q_(capacity) {}
338
339   template <typename... Args>
340   void enqueue(Args&&... args) {
341     q_.blockingWrite(std::forward<Args>(args)...);
342   }
343
344   void dequeue(T& item) {
345     q_.blockingRead(item);
346   }
347
348   bool try_dequeue(T& item) {
349     return q_.read(item);
350   }
351
352   template <typename Clock, typename Duration>
353   bool try_dequeue_until(
354       T& item,
355       const std::chrono::time_point<Clock, Duration>& deadline) {
356     return q_.tryReadUntil(deadline, item);
357   }
358 };
359
360 template <typename T, bool ignore>
361 using FMPMC = MPMC<T, 256 * 1024>;
362
363 template <typename T, size_t capacity>
364 class PCQ {
365   folly::ProducerConsumerQueue<T> q_;
366
367  public:
368   PCQ() : q_(capacity) {}
369
370   template <typename... Args>
371   void enqueue(Args&&... args) {
372     while (!q_.write(std::forward<Args>(args)...)) {
373       /* keep trying*/;
374     }
375   }
376
377   void dequeue(T&) {
378     ASSERT_TRUE(false);
379   }
380
381   bool try_dequeue(T& item) {
382     return q_.read(item);
383   }
384
385   template <typename Clock, typename Duration>
386   bool try_dequeue_until(T&, const std::chrono::time_point<Clock, Duration>&) {
387     return false;
388   }
389 };
390
391 template <typename T, bool ignore>
392 using FPCQ = PCQ<T, 256 * 1024>;
393
394 template <size_t M>
395 struct IntArray {
396   int a[M];
397   IntArray() {}
398   /* implicit */ IntArray(int v) {
399     for (size_t i = 0; i < M; ++i) {
400       a[i] = v;
401     }
402   }
403   operator int() {
404     return a[0];
405   }
406 };
407
408 void dottedLine() {
409   std::cout << ".............................................................."
410             << std::endl;
411 }
412
413 template <typename T>
414 void type_benches(const int np, const int nc, const std::string& name) {
415   std::cout << name
416             << "===========================================" << std::endl;
417   if (np == 1 && nc == 1) {
418     bench<USPSC, T, 0>(1, 1, "Unbounded SPSC try   spin only  ");
419     bench<USPSC, T, 1>(1, 1, "Unbounded SPSC timed spin only  ");
420     bench<USPSC, T, 2>(1, 1, "Unbounded SPSC wait  spin only  ");
421     bench<USPSC, T, 3>(1, 1, "Unbounded SPSC try   may block  ");
422     bench<USPSC, T, 4>(1, 1, "Unbounded SPSC timed may block  ");
423     bench<USPSC, T, 5>(1, 1, "Unbounded SPSC wait  may block  ");
424     dottedLine();
425   }
426   if (nc == 1) {
427     bench<UMPSC, T, 0>(np, 1, "Unbounded MPSC try   spin only  ");
428     bench<UMPSC, T, 1>(np, 1, "Unbounded MPSC timed spin only  ");
429     bench<UMPSC, T, 2>(np, 1, "Unbounded MPSC wait  spin only  ");
430     bench<UMPSC, T, 3>(np, 1, "Unbounded MPSC try   may block  ");
431     bench<UMPSC, T, 4>(np, 1, "Unbounded MPSC timed may block  ");
432     bench<UMPSC, T, 5>(np, 1, "Unbounded MPSC wait  may block  ");
433     dottedLine();
434   }
435   if (np == 1) {
436     bench<USPMC, T, 0>(1, nc, "Unbounded SPMC try   spin only  ");
437     bench<USPMC, T, 1>(1, nc, "Unbounded SPMC timed spin only  ");
438     bench<USPMC, T, 2>(1, nc, "Unbounded SPMC wait  spin only  ");
439     bench<USPMC, T, 3>(1, nc, "Unbounded SPMC try   may block  ");
440     bench<USPMC, T, 4>(1, nc, "Unbounded SPMC timed may block  ");
441     bench<USPMC, T, 5>(1, nc, "Unbounded SPMC wait  may block  ");
442     dottedLine();
443   }
444   bench<UMPMC, T, 0>(np, nc, "Unbounded MPMC try   spin only  ");
445   bench<UMPMC, T, 1>(np, nc, "Unbounded MPMC timed spin only  ");
446   bench<UMPMC, T, 2>(np, nc, "Unbounded MPMC wait  spin only  ");
447   bench<UMPMC, T, 3>(np, nc, "Unbounded MPMC try   may block  ");
448   bench<UMPMC, T, 4>(np, nc, "Unbounded MPMC timed may block  ");
449   bench<UMPMC, T, 5>(np, nc, "Unbounded MPMC wait  may block  ");
450   dottedLine();
451   if (np == 1 && nc == 1) {
452     bench<FPCQ, T, 0>(1, 1, "folly::PCQ  read                ");
453     dottedLine();
454   }
455   bench<FMPMC, T, 3>(np, nc, "folly::MPMC  read               ");
456   bench<FMPMC, T, 4>(np, nc, "folly::MPMC  tryReadUntil       ");
457   bench<FMPMC, T, 5>(np, nc, "folly::MPMC  blockingRead       ");
458   std::cout << "=============================================================="
459             << std::endl;
460 }
461
462 void benches(const int np, const int nc) {
463   std::cout << "====================== " << std::setw(2) << np << " prod"
464             << "  " << std::setw(2) << nc << " cons"
465             << " ======================" << std::endl;
466   type_benches<uint32_t>(np, nc, "=== uint32_t ======");
467   // Benchmarks for other element sizes can be added as follows:
468   //   type_benches<IntArray<4>>(np, nc, "=== IntArray<4> ===");
469 }
470
471 TEST(UnboundedQueue, bench) {
472   if (!FLAGS_bench) {
473     return;
474   }
475   std::cout << "=============================================================="
476             << std::endl;
477   std::cout << std::setw(2) << FLAGS_reps << " reps of " << std::setw(8)
478             << FLAGS_ops << " handoffs\n";
479   dottedLine();
480   std::cout << "$ numactl -N 1 $dir/unbounded_queue_test --bench\n";
481   dottedLine();
482   std::cout << "Using a capacity of 256K for folly::ProducerConsumerQueue\n"
483             << "and folly::MPMCQueue\n";
484   std::cout << "=============================================================="
485             << std::endl;
486   std::cout << "Test name                         Max time  Avg time  Min time"
487             << std::endl;
488
489   for (int nc : {1, 2, 4, 8, 16, 32}) {
490     int np = 1;
491     benches(np, nc);
492   }
493
494   for (int np : {1, 2, 4, 8, 16, 32}) {
495     int nc = 1;
496     benches(np, nc);
497   }
498
499   for (int np : {2, 4, 8, 16, 32}) {
500     for (int nc : {2, 4, 8, 16, 32}) {
501       benches(np, nc);
502     }
503   }
504 }
505
506 /*
507 ==============================================================
508 10 reps of  1000000 handoffs
509 ..............................................................
510 $ numactl -N 1 $dir/unbounded_queue_test --bench
511 ..............................................................
512 Using a capacity of 256K for folly::ProducerConsumerQueue
513 and folly::MPMCQueue
514 ==============================================================
515 Test name                         Max time  Avg time  Min time
516 ======================  1 prod   1 cons ======================
517 === uint32_t =================================================
518 Unbounded SPSC try   spin only        5 ns      5 ns      5 ns
519 Unbounded SPSC timed spin only        5 ns      5 ns      5 ns
520 Unbounded SPSC wait  spin only        6 ns      6 ns      5 ns
521 Unbounded SPSC try   may block       38 ns     37 ns     35 ns
522 Unbounded SPSC timed may block       38 ns     36 ns     34 ns
523 Unbounded SPSC wait  may block       34 ns     34 ns     33 ns
524 ..............................................................
525 Unbounded MPSC try   spin only       45 ns     43 ns     42 ns
526 Unbounded MPSC timed spin only       47 ns     43 ns     42 ns
527 Unbounded MPSC wait  spin only       45 ns     43 ns     41 ns
528 Unbounded MPSC try   may block       55 ns     52 ns     51 ns
529 Unbounded MPSC timed may block       54 ns     52 ns     51 ns
530 Unbounded MPSC wait  may block       51 ns     50 ns     49 ns
531 ..............................................................
532 Unbounded SPMC try   spin only       18 ns     17 ns     16 ns
533 Unbounded SPMC timed spin only       23 ns     21 ns     18 ns
534 Unbounded SPMC wait  spin only       22 ns     19 ns     16 ns
535 Unbounded SPMC try   may block       30 ns     26 ns     22 ns
536 Unbounded SPMC timed may block       32 ns     24 ns     20 ns
537 Unbounded SPMC wait  may block       49 ns     35 ns     29 ns
538 ..............................................................
539 Unbounded MPMC try   spin only       25 ns     24 ns     24 ns
540 Unbounded MPMC timed spin only       38 ns     35 ns     30 ns
541 Unbounded MPMC wait  spin only       41 ns     39 ns     37 ns
542 Unbounded MPMC try   may block       53 ns     52 ns     51 ns
543 Unbounded MPMC timed may block       52 ns     51 ns     49 ns
544 Unbounded MPMC wait  may block       53 ns     51 ns     50 ns
545 ..............................................................
546 folly::PCQ  read                     16 ns     11 ns      7 ns
547 ..............................................................
548 folly::MPMC  read                    52 ns     52 ns     51 ns
549 folly::MPMC  tryReadUntil            96 ns     90 ns     55 ns
550 folly::MPMC  blockingRead            61 ns     56 ns     50 ns
551 ==============================================================
552 ======================  1 prod   2 cons ======================
553 === uint32_t =================================================
554 Unbounded SPMC try   spin only       76 ns     68 ns     53 ns
555 Unbounded SPMC timed spin only       79 ns     71 ns     65 ns
556 Unbounded SPMC wait  spin only       39 ns     35 ns     32 ns
557 Unbounded SPMC try   may block       83 ns     81 ns     76 ns
558 Unbounded SPMC timed may block       86 ns     63 ns     23 ns
559 Unbounded SPMC wait  may block       38 ns     36 ns     34 ns
560 ..............................................................
561 Unbounded MPMC try   spin only       86 ns     79 ns     64 ns
562 Unbounded MPMC timed spin only       84 ns     77 ns     74 ns
563 Unbounded MPMC wait  spin only       36 ns     35 ns     34 ns
564 Unbounded MPMC try   may block       83 ns     79 ns     75 ns
565 Unbounded MPMC timed may block       83 ns     76 ns     63 ns
566 Unbounded MPMC wait  may block       56 ns     48 ns     36 ns
567 ..............................................................
568 folly::MPMC  read                   103 ns     93 ns     68 ns
569 folly::MPMC  tryReadUntil           109 ns    102 ns     91 ns
570 folly::MPMC  blockingRead            61 ns     58 ns     54 ns
571 ==============================================================
572 ======================  1 prod   4 cons ======================
573 === uint32_t =================================================
574 Unbounded SPMC try   spin only      116 ns    109 ns     97 ns
575 Unbounded SPMC timed spin only      117 ns    111 ns    108 ns
576 Unbounded SPMC wait  spin only       43 ns     40 ns     37 ns
577 Unbounded SPMC try   may block      127 ns    113 ns     98 ns
578 Unbounded SPMC timed may block      116 ns    109 ns     97 ns
579 Unbounded SPMC wait  may block       45 ns     43 ns     40 ns
580 ..............................................................
581 Unbounded MPMC try   spin only      121 ns    113 ns    102 ns
582 Unbounded MPMC timed spin only      118 ns    108 ns     88 ns
583 Unbounded MPMC wait  spin only       45 ns     41 ns     34 ns
584 Unbounded MPMC try   may block      117 ns    108 ns     96 ns
585 Unbounded MPMC timed may block      118 ns    109 ns     99 ns
586 Unbounded MPMC wait  may block       62 ns     53 ns     43 ns
587 ..............................................................
588 folly::MPMC  read                   139 ns    130 ns    111 ns
589 folly::MPMC  tryReadUntil           205 ns    135 ns    115 ns
590 folly::MPMC  blockingRead           104 ns     74 ns     54 ns
591 ==============================================================
592 ======================  1 prod   8 cons ======================
593 === uint32_t =================================================
594 Unbounded SPMC try   spin only      169 ns    163 ns    157 ns
595 Unbounded SPMC timed spin only      167 ns    158 ns    133 ns
596 Unbounded SPMC wait  spin only       44 ns     39 ns     36 ns
597 Unbounded SPMC try   may block      170 ns    165 ns    156 ns
598 Unbounded SPMC timed may block      172 ns    163 ns    153 ns
599 Unbounded SPMC wait  may block       49 ns     40 ns     35 ns
600 ..............................................................
601 Unbounded MPMC try   spin only      166 ns    158 ns    149 ns
602 Unbounded MPMC timed spin only      171 ns    161 ns    145 ns
603 Unbounded MPMC wait  spin only       62 ns     52 ns     42 ns
604 Unbounded MPMC try   may block      169 ns    161 ns    149 ns
605 Unbounded MPMC timed may block      170 ns    160 ns    147 ns
606 Unbounded MPMC wait  may block       70 ns     63 ns     61 ns
607 ..............................................................
608 folly::MPMC  read                   174 ns    167 ns    159 ns
609 folly::MPMC  tryReadUntil           349 ns    171 ns    148 ns
610 folly::MPMC  blockingRead           182 ns    138 ns    115 ns
611 ==============================================================
612 ======================  1 prod  16 cons ======================
613 === uint32_t =================================================
614 Unbounded SPMC try   spin only      219 ns    198 ns    190 ns
615 Unbounded SPMC timed spin only      202 ns    198 ns    193 ns
616 Unbounded SPMC wait  spin only       36 ns     36 ns     35 ns
617 Unbounded SPMC try   may block      202 ns    195 ns    190 ns
618 Unbounded SPMC timed may block      208 ns    197 ns    190 ns
619 Unbounded SPMC wait  may block     1645 ns   1427 ns     36 ns
620 ..............................................................
621 Unbounded MPMC try   spin only      204 ns    198 ns    194 ns
622 Unbounded MPMC timed spin only      202 ns    195 ns    190 ns
623 Unbounded MPMC wait  spin only       61 ns     59 ns     57 ns
624 Unbounded MPMC try   may block      206 ns    196 ns    191 ns
625 Unbounded MPMC timed may block      204 ns    198 ns    192 ns
626 Unbounded MPMC wait  may block     1658 ns   1293 ns     70 ns
627 ..............................................................
628 folly::MPMC  read                   210 ns    191 ns    182 ns
629 folly::MPMC  tryReadUntil           574 ns    248 ns    192 ns
630 folly::MPMC  blockingRead          1400 ns   1319 ns   1227 ns
631 ==============================================================
632 ======================  1 prod  32 cons ======================
633 === uint32_t =================================================
634 Unbounded SPMC try   spin only      209 ns    205 ns    199 ns
635 Unbounded SPMC timed spin only      208 ns    205 ns    200 ns
636 Unbounded SPMC wait  spin only      175 ns     51 ns     33 ns
637 Unbounded SPMC try   may block      215 ns    203 ns    186 ns
638 Unbounded SPMC timed may block      453 ns    334 ns    204 ns
639 Unbounded SPMC wait  may block     1601 ns   1514 ns   1373 ns
640 ..............................................................
641 Unbounded MPMC try   spin only      328 ns    218 ns    197 ns
642 Unbounded MPMC timed spin only      217 ns    206 ns    200 ns
643 Unbounded MPMC wait  spin only      147 ns     85 ns     58 ns
644 Unbounded MPMC try   may block      310 ns    223 ns    199 ns
645 Unbounded MPMC timed may block      461 ns    275 ns    196 ns
646 Unbounded MPMC wait  may block     1623 ns   1526 ns    888 ns
647 ..............................................................
648 folly::MPMC  read                   280 ns    215 ns    194 ns
649 folly::MPMC  tryReadUntil          28740 ns   13508 ns    212 ns
650 folly::MPMC  blockingRead          1343 ns   1293 ns   1269 ns
651 ==============================================================
652 ======================  1 prod   1 cons ======================
653 === uint32_t =================================================
654 Unbounded SPSC try   spin only        5 ns      5 ns      5 ns
655 Unbounded SPSC timed spin only        8 ns      6 ns      6 ns
656 Unbounded SPSC wait  spin only        6 ns      6 ns      5 ns
657 Unbounded SPSC try   may block       37 ns     36 ns     35 ns
658 Unbounded SPSC timed may block       37 ns     36 ns     35 ns
659 Unbounded SPSC wait  may block       35 ns     35 ns     34 ns
660 ..............................................................
661 Unbounded MPSC try   spin only       43 ns     42 ns     41 ns
662 Unbounded MPSC timed spin only       45 ns     42 ns     42 ns
663 Unbounded MPSC wait  spin only       44 ns     43 ns     42 ns
664 Unbounded MPSC try   may block       55 ns     51 ns     50 ns
665 Unbounded MPSC timed may block       61 ns     52 ns     50 ns
666 Unbounded MPSC wait  may block       54 ns     52 ns     50 ns
667 ..............................................................
668 Unbounded SPMC try   spin only       18 ns     17 ns     17 ns
669 Unbounded SPMC timed spin only       23 ns     19 ns     17 ns
670 Unbounded SPMC wait  spin only       20 ns     17 ns     15 ns
671 Unbounded SPMC try   may block       30 ns     23 ns     19 ns
672 Unbounded SPMC timed may block       23 ns     19 ns     17 ns
673 Unbounded SPMC wait  may block       36 ns     31 ns     26 ns
674 ..............................................................
675 Unbounded MPMC try   spin only       25 ns     23 ns     17 ns
676 Unbounded MPMC timed spin only       37 ns     34 ns     25 ns
677 Unbounded MPMC wait  spin only       40 ns     38 ns     36 ns
678 Unbounded MPMC try   may block       51 ns     49 ns     48 ns
679 Unbounded MPMC timed may block       53 ns     50 ns     48 ns
680 Unbounded MPMC wait  may block       53 ns     49 ns     34 ns
681 ..............................................................
682 folly::PCQ  read                     15 ns     12 ns      7 ns
683 ..............................................................
684 folly::MPMC  read                    53 ns     51 ns     50 ns
685 folly::MPMC  tryReadUntil           100 ns     96 ns     90 ns
686 folly::MPMC  blockingRead            75 ns     59 ns     52 ns
687 ==============================================================
688 ======================  2 prod   1 cons ======================
689 === uint32_t =================================================
690 Unbounded MPSC try   spin only       49 ns     49 ns     46 ns
691 Unbounded MPSC timed spin only       52 ns     50 ns     49 ns
692 Unbounded MPSC wait  spin only       53 ns     52 ns     51 ns
693 Unbounded MPSC try   may block       63 ns     60 ns     57 ns
694 Unbounded MPSC timed may block       64 ns     61 ns     54 ns
695 Unbounded MPSC wait  may block       62 ns     59 ns     35 ns
696 ..............................................................
697 Unbounded MPMC try   spin only       44 ns     41 ns     38 ns
698 Unbounded MPMC timed spin only       50 ns     49 ns     49 ns
699 Unbounded MPMC wait  spin only       51 ns     49 ns     49 ns
700 Unbounded MPMC try   may block       63 ns     60 ns     57 ns
701 Unbounded MPMC timed may block       62 ns     60 ns     57 ns
702 Unbounded MPMC wait  may block       62 ns     60 ns     58 ns
703 ..............................................................
704 folly::MPMC  read                    78 ns     57 ns     52 ns
705 folly::MPMC  tryReadUntil            78 ns     72 ns     70 ns
706 folly::MPMC  blockingRead            56 ns     54 ns     52 ns
707 ==============================================================
708 ======================  4 prod   1 cons ======================
709 === uint32_t =================================================
710 Unbounded MPSC try   spin only       48 ns     47 ns     46 ns
711 Unbounded MPSC timed spin only       47 ns     47 ns     46 ns
712 Unbounded MPSC wait  spin only       49 ns     47 ns     47 ns
713 Unbounded MPSC try   may block       61 ns     59 ns     55 ns
714 Unbounded MPSC timed may block       62 ns     58 ns     46 ns
715 Unbounded MPSC wait  may block       62 ns     61 ns     59 ns
716 ..............................................................
717 Unbounded MPMC try   spin only       42 ns     42 ns     40 ns
718 Unbounded MPMC timed spin only       48 ns     47 ns     45 ns
719 Unbounded MPMC wait  spin only       48 ns     47 ns     46 ns
720 Unbounded MPMC try   may block       63 ns     62 ns     61 ns
721 Unbounded MPMC timed may block       63 ns     61 ns     51 ns
722 Unbounded MPMC wait  may block       62 ns     61 ns     59 ns
723 ..............................................................
724 folly::MPMC  read                    56 ns     55 ns     54 ns
725 folly::MPMC  tryReadUntil           112 ns    106 ns     97 ns
726 folly::MPMC  blockingRead            47 ns     47 ns     45 ns
727 ==============================================================
728 ======================  8 prod   1 cons ======================
729 === uint32_t =================================================
730 Unbounded MPSC try   spin only       44 ns     43 ns     42 ns
731 Unbounded MPSC timed spin only       45 ns     44 ns     40 ns
732 Unbounded MPSC wait  spin only       45 ns     44 ns     41 ns
733 Unbounded MPSC try   may block       61 ns     60 ns     58 ns
734 Unbounded MPSC timed may block       61 ns     59 ns     56 ns
735 Unbounded MPSC wait  may block       61 ns     59 ns     56 ns
736 ..............................................................
737 Unbounded MPMC try   spin only       43 ns     40 ns     36 ns
738 Unbounded MPMC timed spin only       45 ns     44 ns     41 ns
739 Unbounded MPMC wait  spin only       45 ns     43 ns     41 ns
740 Unbounded MPMC try   may block       62 ns     60 ns     58 ns
741 Unbounded MPMC timed may block       62 ns     59 ns     56 ns
742 Unbounded MPMC wait  may block       61 ns     58 ns     54 ns
743 ..............................................................
744 folly::MPMC  read                   147 ns    119 ns     63 ns
745 folly::MPMC  tryReadUntil           152 ns    130 ns     97 ns
746 folly::MPMC  blockingRead           135 ns    101 ns     48 ns
747 ==============================================================
748 ====================== 16 prod   1 cons ======================
749 === uint32_t =================================================
750 Unbounded MPSC try   spin only       47 ns     38 ns     35 ns
751 Unbounded MPSC timed spin only       36 ns     36 ns     35 ns
752 Unbounded MPSC wait  spin only       46 ns     37 ns     35 ns
753 Unbounded MPSC try   may block       58 ns     47 ns     45 ns
754 Unbounded MPSC timed may block       46 ns     46 ns     45 ns
755 Unbounded MPSC wait  may block       47 ns     45 ns     45 ns
756 ..............................................................
757 Unbounded MPMC try   spin only       41 ns     39 ns     35 ns
758 Unbounded MPMC timed spin only       45 ns     41 ns     38 ns
759 Unbounded MPMC wait  spin only       43 ns     40 ns     38 ns
760 Unbounded MPMC try   may block       51 ns     49 ns     47 ns
761 Unbounded MPMC timed may block       52 ns     49 ns     47 ns
762 Unbounded MPMC wait  may block       59 ns     50 ns     46 ns
763 ..............................................................
764 folly::MPMC  read                   924 ns    839 ns    664 ns
765 folly::MPMC  tryReadUntil           968 ns    865 ns    678 ns
766 folly::MPMC  blockingRead           929 ns    727 ns    487 ns
767 ==============================================================
768 ====================== 32 prod   1 cons ======================
769 === uint32_t =================================================
770 Unbounded MPSC try   spin only       90 ns     44 ns     36 ns
771 Unbounded MPSC timed spin only       91 ns     43 ns     35 ns
772 Unbounded MPSC wait  spin only       92 ns     55 ns     36 ns
773 Unbounded MPSC try   may block       87 ns     52 ns     45 ns
774 Unbounded MPSC timed may block       70 ns     48 ns     45 ns
775 Unbounded MPSC wait  may block      109 ns     60 ns     45 ns
776 ..............................................................
777 Unbounded MPMC try   spin only       47 ns     42 ns     37 ns
778 Unbounded MPMC timed spin only       50 ns     46 ns     38 ns
779 Unbounded MPMC wait  spin only       50 ns     42 ns     36 ns
780 Unbounded MPMC try   may block      103 ns     59 ns     50 ns
781 Unbounded MPMC timed may block       56 ns     52 ns     47 ns
782 Unbounded MPMC wait  may block       59 ns     51 ns     46 ns
783 ..............................................................
784 folly::MPMC  read                  1029 ns    911 ns    694 ns
785 folly::MPMC  tryReadUntil          1023 ns    969 ns    907 ns
786 folly::MPMC  blockingRead          1024 ns    921 ns    790 ns
787 ==============================================================
788 ======================  2 prod   2 cons ======================
789 === uint32_t =================================================
790 Unbounded MPMC try   spin only       83 ns     66 ns     24 ns
791 Unbounded MPMC timed spin only       84 ns     74 ns     49 ns
792 Unbounded MPMC wait  spin only       50 ns     49 ns     47 ns
793 Unbounded MPMC try   may block       86 ns     81 ns     77 ns
794 Unbounded MPMC timed may block       82 ns     74 ns     59 ns
795 Unbounded MPMC wait  may block       62 ns     59 ns     56 ns
796 ..............................................................
797 folly::MPMC  read                    98 ns     85 ns     63 ns
798 folly::MPMC  tryReadUntil           105 ns     94 ns     83 ns
799 folly::MPMC  blockingRead            59 ns     56 ns     54 ns
800 ==============================================================
801 ======================  2 prod   4 cons ======================
802 === uint32_t =================================================
803 Unbounded MPMC try   spin only      114 ns    105 ns     91 ns
804 Unbounded MPMC timed spin only      119 ns    107 ns    102 ns
805 Unbounded MPMC wait  spin only       54 ns     53 ns     52 ns
806 Unbounded MPMC try   may block      114 ns    106 ns     93 ns
807 Unbounded MPMC timed may block      111 ns    100 ns     92 ns
808 Unbounded MPMC wait  may block       70 ns     64 ns     60 ns
809 ..............................................................
810 folly::MPMC  read                   133 ns    125 ns    120 ns
811 folly::MPMC  tryReadUntil           130 ns    125 ns    114 ns
812 folly::MPMC  blockingRead            69 ns     68 ns     66 ns
813 ==============================================================
814 ======================  2 prod   8 cons ======================
815 === uint32_t =================================================
816 Unbounded MPMC try   spin only      169 ns    160 ns    152 ns
817 Unbounded MPMC timed spin only      165 ns    158 ns    149 ns
818 Unbounded MPMC wait  spin only       59 ns     54 ns     45 ns
819 Unbounded MPMC try   may block      166 ns    158 ns    131 ns
820 Unbounded MPMC timed may block      168 ns    163 ns    158 ns
821 Unbounded MPMC wait  may block       73 ns     66 ns     60 ns
822 ..............................................................
823 folly::MPMC  read                   170 ns    167 ns    160 ns
824 folly::MPMC  tryReadUntil           163 ns    154 ns    146 ns
825 folly::MPMC  blockingRead            82 ns     73 ns     60 ns
826 ==============================================================
827 ======================  2 prod  16 cons ======================
828 === uint32_t =================================================
829 Unbounded MPMC try   spin only      207 ns    198 ns    191 ns
830 Unbounded MPMC timed spin only      211 ns    198 ns    192 ns
831 Unbounded MPMC wait  spin only       57 ns     55 ns     54 ns
832 Unbounded MPMC try   may block      197 ns    193 ns    188 ns
833 Unbounded MPMC timed may block      201 ns    195 ns    188 ns
834 Unbounded MPMC wait  may block       89 ns     78 ns     70 ns
835 ..............................................................
836 folly::MPMC  read                   196 ns    189 ns    181 ns
837 folly::MPMC  tryReadUntil           202 ns    184 ns    173 ns
838 folly::MPMC  blockingRead           267 ns    100 ns     76 ns
839 ==============================================================
840 ======================  2 prod  32 cons ======================
841 === uint32_t =================================================
842 Unbounded MPMC try   spin only      228 ns    207 ns    193 ns
843 Unbounded MPMC timed spin only      210 ns    205 ns    198 ns
844 Unbounded MPMC wait  spin only      102 ns     71 ns     56 ns
845 Unbounded MPMC try   may block      268 ns    211 ns    198 ns
846 Unbounded MPMC timed may block      226 ns    205 ns    183 ns
847 Unbounded MPMC wait  may block      502 ns    164 ns     67 ns
848 ..............................................................
849 folly::MPMC  read                   228 ns    205 ns    195 ns
850 folly::MPMC  tryReadUntil           207 ns    200 ns    192 ns
851 folly::MPMC  blockingRead           830 ns    612 ns    192 ns
852 ==============================================================
853 ======================  4 prod   2 cons ======================
854 === uint32_t =================================================
855 Unbounded MPMC try   spin only       87 ns     65 ns     33 ns
856 Unbounded MPMC timed spin only       79 ns     60 ns     36 ns
857 Unbounded MPMC wait  spin only       47 ns     46 ns     44 ns
858 Unbounded MPMC try   may block       87 ns     77 ns     52 ns
859 Unbounded MPMC timed may block       86 ns     79 ns     57 ns
860 Unbounded MPMC wait  may block       62 ns     61 ns     60 ns
861 ..............................................................
862 folly::MPMC  read                   110 ns     95 ns     60 ns
863 folly::MPMC  tryReadUntil           108 ns    104 ns     96 ns
864 folly::MPMC  blockingRead            60 ns     57 ns     47 ns
865 ==============================================================
866 ======================  4 prod   4 cons ======================
867 === uint32_t =================================================
868 Unbounded MPMC try   spin only      110 ns    100 ns     86 ns
869 Unbounded MPMC timed spin only      113 ns    104 ns     93 ns
870 Unbounded MPMC wait  spin only       49 ns     46 ns     45 ns
871 Unbounded MPMC try   may block      115 ns    105 ns     84 ns
872 Unbounded MPMC timed may block      119 ns    108 ns     89 ns
873 Unbounded MPMC wait  may block       63 ns     61 ns     54 ns
874 ..............................................................
875 folly::MPMC  read                   140 ns    131 ns    113 ns
876 folly::MPMC  tryReadUntil           132 ns    129 ns    121 ns
877 folly::MPMC  blockingRead            58 ns     53 ns     48 ns
878 ==============================================================
879 ======================  4 prod   8 cons ======================
880 === uint32_t =================================================
881 Unbounded MPMC try   spin only      170 ns    162 ns    151 ns
882 Unbounded MPMC timed spin only      174 ns    158 ns    139 ns
883 Unbounded MPMC wait  spin only       51 ns     50 ns     48 ns
884 Unbounded MPMC try   may block      164 ns    160 ns    154 ns
885 Unbounded MPMC timed may block      165 ns    158 ns    144 ns
886 Unbounded MPMC wait  may block       67 ns     62 ns     52 ns
887 ..............................................................
888 folly::MPMC  read                   174 ns    166 ns    156 ns
889 folly::MPMC  tryReadUntil           165 ns    160 ns    150 ns
890 folly::MPMC  blockingRead            58 ns     56 ns     49 ns
891 ==============================================================
892 ======================  4 prod  16 cons ======================
893 === uint32_t =================================================
894 Unbounded MPMC try   spin only      200 ns    195 ns    181 ns
895 Unbounded MPMC timed spin only      200 ns    195 ns    191 ns
896 Unbounded MPMC wait  spin only       51 ns     49 ns     45 ns
897 Unbounded MPMC try   may block      198 ns    192 ns    188 ns
898 Unbounded MPMC timed may block      199 ns    190 ns    182 ns
899 Unbounded MPMC wait  may block       77 ns     66 ns     60 ns
900 ..............................................................
901 folly::MPMC  read                   195 ns    186 ns    175 ns
902 folly::MPMC  tryReadUntil           204 ns    187 ns    167 ns
903 folly::MPMC  blockingRead            66 ns     60 ns     57 ns
904 ==============================================================
905 ======================  4 prod  32 cons ======================
906 === uint32_t =================================================
907 Unbounded MPMC try   spin only      246 ns    210 ns    195 ns
908 Unbounded MPMC timed spin only      217 ns    207 ns    199 ns
909 Unbounded MPMC wait  spin only       66 ns     52 ns     46 ns
910 Unbounded MPMC try   may block      250 ns    207 ns    197 ns
911 Unbounded MPMC timed may block      208 ns    202 ns    195 ns
912 Unbounded MPMC wait  may block       80 ns     66 ns     56 ns
913 ..............................................................
914 folly::MPMC  read                   231 ns    201 ns    190 ns
915 folly::MPMC  tryReadUntil           202 ns    199 ns    196 ns
916 folly::MPMC  blockingRead            65 ns     61 ns     57 ns
917 ==============================================================
918 ======================  8 prod   2 cons ======================
919 === uint32_t =================================================
920 Unbounded MPMC try   spin only       50 ns     41 ns     39 ns
921 Unbounded MPMC timed spin only       73 ns     49 ns     40 ns
922 Unbounded MPMC wait  spin only       46 ns     43 ns     39 ns
923 Unbounded MPMC try   may block       81 ns     62 ns     56 ns
924 Unbounded MPMC timed may block       75 ns     61 ns     53 ns
925 Unbounded MPMC wait  may block       61 ns     57 ns     50 ns
926 ..............................................................
927 folly::MPMC  read                   120 ns    102 ns     58 ns
928 folly::MPMC  tryReadUntil           119 ns    112 ns    103 ns
929 folly::MPMC  blockingRead            85 ns     71 ns     58 ns
930 ==============================================================
931 ======================  8 prod   4 cons ======================
932 === uint32_t =================================================
933 Unbounded MPMC try   spin only      104 ns     87 ns     39 ns
934 Unbounded MPMC timed spin only      109 ns     89 ns     40 ns
935 Unbounded MPMC wait  spin only       46 ns     45 ns     43 ns
936 Unbounded MPMC try   may block      121 ns    101 ns     74 ns
937 Unbounded MPMC timed may block      116 ns    103 ns     72 ns
938 Unbounded MPMC wait  may block       62 ns     57 ns     52 ns
939 ..............................................................
940 folly::MPMC  read                   136 ns    130 ns    118 ns
941 folly::MPMC  tryReadUntil           132 ns    127 ns    118 ns
942 folly::MPMC  blockingRead            68 ns     61 ns     51 ns
943 ==============================================================
944 ======================  8 prod   8 cons ======================
945 === uint32_t =================================================
946 Unbounded MPMC try   spin only      175 ns    171 ns    162 ns
947 Unbounded MPMC timed spin only      177 ns    169 ns    159 ns
948 Unbounded MPMC wait  spin only       49 ns     47 ns     45 ns
949 Unbounded MPMC try   may block      175 ns    171 ns    156 ns
950 Unbounded MPMC timed may block      180 ns    170 ns    162 ns
951 Unbounded MPMC wait  may block       63 ns     62 ns     59 ns
952 ..............................................................
953 folly::MPMC  read                   177 ns    162 ns    147 ns
954 folly::MPMC  tryReadUntil           170 ns    162 ns    148 ns
955 folly::MPMC  blockingRead            57 ns     53 ns     49 ns
956 ==============================================================
957 ======================  8 prod  16 cons ======================
958 === uint32_t =================================================
959 Unbounded MPMC try   spin only      203 ns    192 ns    185 ns
960 Unbounded MPMC timed spin only      199 ns    193 ns    185 ns
961 Unbounded MPMC wait  spin only       48 ns     46 ns     44 ns
962 Unbounded MPMC try   may block      204 ns    194 ns    182 ns
963 Unbounded MPMC timed may block      198 ns    187 ns    171 ns
964 Unbounded MPMC wait  may block       63 ns     61 ns     57 ns
965 ..............................................................
966 folly::MPMC  read                   193 ns    185 ns    167 ns
967 folly::MPMC  tryReadUntil           199 ns    188 ns    164 ns
968 folly::MPMC  blockingRead            57 ns     52 ns     49 ns
969 ==============================================================
970 ======================  8 prod  32 cons ======================
971 === uint32_t =================================================
972 Unbounded MPMC try   spin only      222 ns    208 ns    198 ns
973 Unbounded MPMC timed spin only      234 ns    212 ns    203 ns
974 Unbounded MPMC wait  spin only       89 ns     58 ns     45 ns
975 Unbounded MPMC try   may block      234 ns    207 ns    196 ns
976 Unbounded MPMC timed may block      205 ns    203 ns    197 ns
977 Unbounded MPMC wait  may block       65 ns     63 ns     61 ns
978 ..............................................................
979 folly::MPMC  read                   240 ns    204 ns    194 ns
980 folly::MPMC  tryReadUntil           205 ns    202 ns    199 ns
981 folly::MPMC  blockingRead            56 ns     52 ns     49 ns
982 ==============================================================
983 ====================== 16 prod   2 cons ======================
984 === uint32_t =================================================
985 Unbounded MPMC try   spin only       52 ns     40 ns     34 ns
986 Unbounded MPMC timed spin only       63 ns     47 ns     36 ns
987 Unbounded MPMC wait  spin only       45 ns     39 ns     36 ns
988 Unbounded MPMC try   may block       62 ns     51 ns     47 ns
989 Unbounded MPMC timed may block       77 ns     52 ns     46 ns
990 Unbounded MPMC wait  may block       63 ns     50 ns     46 ns
991 ..............................................................
992 folly::MPMC  read                   114 ns    103 ns     77 ns
993 folly::MPMC  tryReadUntil           116 ns    106 ns     85 ns
994 folly::MPMC  blockingRead            85 ns     79 ns     63 ns
995 ==============================================================
996 ====================== 16 prod   4 cons ======================
997 === uint32_t =================================================
998 Unbounded MPMC try   spin only      106 ns     68 ns     33 ns
999 Unbounded MPMC timed spin only       88 ns     56 ns     36 ns
1000 Unbounded MPMC wait  spin only       46 ns     39 ns     35 ns
1001 Unbounded MPMC try   may block       95 ns     66 ns     47 ns
1002 Unbounded MPMC timed may block       80 ns     57 ns     46 ns
1003 Unbounded MPMC wait  may block       52 ns     48 ns     45 ns
1004 ..............................................................
1005 folly::MPMC  read                   121 ns    113 ns    104 ns
1006 folly::MPMC  tryReadUntil           119 ns    110 ns    101 ns
1007 folly::MPMC  blockingRead            65 ns     62 ns     57 ns
1008 ==============================================================
1009 ====================== 16 prod   8 cons ======================
1010 === uint32_t =================================================
1011 Unbounded MPMC try   spin only      153 ns    109 ns     46 ns
1012 Unbounded MPMC timed spin only      167 ns    110 ns     36 ns
1013 Unbounded MPMC wait  spin only       43 ns     39 ns     36 ns
1014 Unbounded MPMC try   may block      159 ns    125 ns    100 ns
1015 Unbounded MPMC timed may block      127 ns     82 ns     52 ns
1016 Unbounded MPMC wait  may block       51 ns     50 ns     46 ns
1017 ..............................................................
1018 folly::MPMC  read                   149 ns    139 ns    129 ns
1019 folly::MPMC  tryReadUntil           141 ns    134 ns    112 ns
1020 folly::MPMC  blockingRead            59 ns     54 ns     49 ns
1021 ==============================================================
1022 ====================== 16 prod  16 cons ======================
1023 === uint32_t =================================================
1024 Unbounded MPMC try   spin only      193 ns    169 ns    148 ns
1025 Unbounded MPMC timed spin only      221 ns    175 ns    106 ns
1026 Unbounded MPMC wait  spin only       45 ns     41 ns     37 ns
1027 Unbounded MPMC try   may block      204 ns    171 ns    133 ns
1028 Unbounded MPMC timed may block      184 ns    162 ns    104 ns
1029 Unbounded MPMC wait  may block       61 ns     52 ns     49 ns
1030 ..............................................................
1031 folly::MPMC  read                   181 ns    164 ns    157 ns
1032 folly::MPMC  tryReadUntil           185 ns    173 ns    157 ns
1033 folly::MPMC  blockingRead            56 ns     50 ns     45 ns
1034 ==============================================================
1035 ====================== 16 prod  32 cons ======================
1036 === uint32_t =================================================
1037 Unbounded MPMC try   spin only      255 ns    217 ns    181 ns
1038 Unbounded MPMC timed spin only      225 ns    205 ns    182 ns
1039 Unbounded MPMC wait  spin only      115 ns     57 ns     40 ns
1040 Unbounded MPMC try   may block      215 ns    199 ns    184 ns
1041 Unbounded MPMC timed may block      218 ns    196 ns    179 ns
1042 Unbounded MPMC wait  may block       63 ns     54 ns     47 ns
1043 ..............................................................
1044 folly::MPMC  read                   260 ns    205 ns    185 ns
1045 folly::MPMC  tryReadUntil           205 ns    200 ns    192 ns
1046 folly::MPMC  blockingRead            53 ns     48 ns     43 ns
1047 ==============================================================
1048 ====================== 32 prod   2 cons ======================
1049 === uint32_t =================================================
1050 Unbounded MPMC try   spin only       95 ns     66 ns     45 ns
1051 Unbounded MPMC timed spin only       95 ns     62 ns     45 ns
1052 Unbounded MPMC wait  spin only       56 ns     44 ns     36 ns
1053 Unbounded MPMC try   may block      123 ns     86 ns     50 ns
1054 Unbounded MPMC timed may block      109 ns     73 ns     47 ns
1055 Unbounded MPMC wait  may block       95 ns     58 ns     47 ns
1056 ..............................................................
1057 folly::MPMC  read                   445 ns    380 ns    315 ns
1058 folly::MPMC  tryReadUntil           459 ns    341 ns    153 ns
1059 folly::MPMC  blockingRead           351 ns    286 ns    218 ns
1060 ==============================================================
1061 ====================== 32 prod   4 cons ======================
1062 === uint32_t =================================================
1063 Unbounded MPMC try   spin only      114 ns     92 ns     59 ns
1064 Unbounded MPMC timed spin only      135 ns     99 ns     47 ns
1065 Unbounded MPMC wait  spin only      139 ns     55 ns     38 ns
1066 Unbounded MPMC try   may block      165 ns    113 ns     72 ns
1067 Unbounded MPMC timed may block      119 ns     94 ns     51 ns
1068 Unbounded MPMC wait  may block       61 ns     52 ns     47 ns
1069 ..............................................................
1070 folly::MPMC  read                   127 ns    112 ns     93 ns
1071 folly::MPMC  tryReadUntil           116 ns    107 ns     96 ns
1072 folly::MPMC  blockingRead            67 ns     59 ns     51 ns
1073 ==============================================================
1074 ====================== 32 prod   8 cons ======================
1075 === uint32_t =================================================
1076 Unbounded MPMC try   spin only      226 ns    140 ns     57 ns
1077 Unbounded MPMC timed spin only      176 ns    126 ns     61 ns
1078 Unbounded MPMC wait  spin only       86 ns     50 ns     39 ns
1079 Unbounded MPMC try   may block      170 ns    131 ns     76 ns
1080 Unbounded MPMC timed may block      201 ns    141 ns    110 ns
1081 Unbounded MPMC wait  may block       94 ns     55 ns     47 ns
1082 ..............................................................
1083 folly::MPMC  read                   148 ns    131 ns    120 ns
1084 folly::MPMC  tryReadUntil           132 ns    126 ns    121 ns
1085 folly::MPMC  blockingRead            59 ns     54 ns     51 ns
1086 ==============================================================
1087 ====================== 32 prod  16 cons ======================
1088 === uint32_t =================================================
1089 Unbounded MPMC try   spin only      209 ns    174 ns    146 ns
1090 Unbounded MPMC timed spin only      214 ns    189 ns    154 ns
1091 Unbounded MPMC wait  spin only      138 ns     51 ns     38 ns
1092 Unbounded MPMC try   may block      247 ns    191 ns    144 ns
1093 Unbounded MPMC timed may block      245 ns    180 ns    123 ns
1094 Unbounded MPMC wait  may block       74 ns     51 ns     46 ns
1095 ..............................................................
1096 folly::MPMC  read                   164 ns    148 ns    135 ns
1097 folly::MPMC  tryReadUntil           156 ns    149 ns    140 ns
1098 folly::MPMC  blockingRead            55 ns     50 ns     47 ns
1099 ==============================================================
1100 ====================== 32 prod  32 cons ======================
1101 === uint32_t =================================================
1102 Unbounded MPMC try   spin only      255 ns    212 ns    179 ns
1103 Unbounded MPMC timed spin only      391 ns    223 ns    147 ns
1104 Unbounded MPMC wait  spin only       78 ns     44 ns     38 ns
1105 Unbounded MPMC try   may block      516 ns    249 ns    195 ns
1106 Unbounded MPMC timed may block      293 ns    210 ns    171 ns
1107 Unbounded MPMC wait  may block       54 ns     51 ns     48 ns
1108 ..............................................................
1109 folly::MPMC  read                   195 ns    183 ns    164 ns
1110 folly::MPMC  tryReadUntil           191 ns    175 ns    159 ns
1111 folly::MPMC  blockingRead            49 ns     45 ns     43 ns
1112 ==============================================================
1113
1114 $ lscpu
1115 Architecture:        x86_64
1116 CPU op-mode(s):      32-bit, 64-bit
1117 Byte Order:          Little Endian
1118 CPU(s):              32
1119 On-line CPU(s) list: 0-31
1120 Thread(s) per core:  2
1121 Core(s) per socket:  8
1122 Socket(s):           2
1123 NUMA node(s):        2
1124 Vendor ID:           GenuineIntel
1125 CPU family:          6
1126 Model:               45
1127 Model name:          Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz
1128 Stepping:            6
1129 CPU MHz:             2200.000
1130 CPU max MHz:         2200.0000
1131 CPU min MHz:         1200.0000
1132 BogoMIPS:            4399.92
1133 Virtualization:      VT-x
1134 L1d cache:           32K
1135 L1i cache:           32K
1136 L2 cache:            256K
1137 L3 cache:            20480K
1138 NUMA node0 CPU(s):   0-7,16-23
1139 NUMA node1 CPU(s):   8-15,24-31
1140
1141 Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
1142                      pge mca cmov pat pse36 clflush dts acpi mmx fxsr
1143                      sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp
1144                      lm constant_tsc arch_perfmon pebs bts rep_good
1145                      nopl xtopology nonstop_tsc aperfmperf eagerfpu
1146                      pni pclmulqdq dtes64 monitor ds_cpl vmx smx est
1147                      tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2
1148                      x2apic popcnt tsc_deadline_timer aes xsave avx
1149                      lahf_lm epb tpr_shadow vnmi flexpriority ept vpid
1150                      xsaveopt dtherm arat pln pts
1151  */