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