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