Commits


Antoine Pitrou authored and Wes McKinney committed b29ecdce6e0
ARROW-4177: [C++] Add ThreadPool and TaskGroup microbenchmarks These benchmarks measure the number of tasks per second that can be executed depending on task cost and number of threads. It shows that for short tasks (< 10 µs), the scalability can be poor or even negative for very short tasks (< 1 µs). Also includes an optimization of ThreadedTaskGroup to avoid taking a lock on the hot path. Sample output (8-core AMD CPU, Ubuntu 18.04): ``` ----------------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------------------------------------------------------------- BM_WorkloadCost/task_cost:1000/repeats:1 724 ns 724 ns 987295 1.31655M items/s BM_WorkloadCost/task_cost:10000/repeats:1 7331 ns 7330 ns 88982 133.23k items/s BM_WorkloadCost/task_cost:100000/repeats:1 73279 ns 73267 ns 9182 13.3288k items/s BM_ThreadPoolSpawn/threads:1/task_cost:1000/repeats:1/real_time 163842359 ns 41132762 ns 4 1.16414M items/s BM_ThreadPoolSpawn/threads:2/task_cost:1000/repeats:1/real_time 158705340 ns 103873994 ns 7 1.20182M items/s BM_ThreadPoolSpawn/threads:4/task_cost:1000/repeats:1/real_time 447998576 ns 370986805 ns 2 435.969k items/s BM_ThreadPoolSpawn/threads:8/task_cost:1000/repeats:1/real_time 674500180 ns 543967794 ns 1 289.568k items/s BM_ThreadPoolSpawn/threads:1/task_cost:10000/repeats:1/real_time 150078690 ns 4887868 ns 5 130.147k items/s BM_ThreadPoolSpawn/threads:2/task_cost:10000/repeats:1/real_time 84446492 ns 5402850 ns 8 231.297k items/s BM_ThreadPoolSpawn/threads:4/task_cost:10000/repeats:1/real_time 46164089 ns 4912818 ns 15 423.104k items/s BM_ThreadPoolSpawn/threads:8/task_cost:10000/repeats:1/real_time 22703512 ns 7074437 ns 31 860.317k items/s BM_ThreadPoolSpawn/threads:1/task_cost:100000/repeats:1/real_time 149733023 ns 515907 ns 4 13.0506k items/s BM_ThreadPoolSpawn/threads:2/task_cost:100000/repeats:1/real_time 81157195 ns 448091 ns 9 24.078k items/s BM_ThreadPoolSpawn/threads:4/task_cost:100000/repeats:1/real_time 45600571 ns 521094 ns 16 42.8526k items/s BM_ThreadPoolSpawn/threads:8/task_cost:100000/repeats:1/real_time 20867873 ns 359547 ns 32 93.6416k items/s BM_SerialTaskGroup/task_cost:1000/repeats:1/real_time 8366557 ns 8362959 ns 66 1.13998M items/s BM_SerialTaskGroup/task_cost:10000/repeats:1/real_time 8346475 ns 8345288 ns 75 117.12k items/s BM_SerialTaskGroup/task_cost:100000/repeats:1/real_time 8409974 ns 8408879 ns 80 11.7281k items/s BM_ThreadedTaskGroup/threads:1/task_cost:1000/repeats:1/real_time 12932016 ns 6283623 ns 60 755.227k items/s BM_ThreadedTaskGroup/threads:2/task_cost:1000/repeats:1/real_time 10622580 ns 8631946 ns 58 919.419k items/s BM_ThreadedTaskGroup/threads:4/task_cost:1000/repeats:1/real_time 25544253 ns 20347053 ns 25 382.34k items/s BM_ThreadedTaskGroup/threads:8/task_cost:1000/repeats:1/real_time 36215077 ns 29435817 ns 19 269.683k items/s BM_ThreadedTaskGroup/threads:1/task_cost:10000/repeats:1/real_time 9830469 ns 476288 ns 69 99.4397k items/s BM_ThreadedTaskGroup/threads:2/task_cost:10000/repeats:1/real_time 5446608 ns 546159 ns 116 179.477k items/s BM_ThreadedTaskGroup/threads:4/task_cost:10000/repeats:1/real_time 2858316 ns 666944 ns 247 341.998k items/s BM_ThreadedTaskGroup/threads:8/task_cost:10000/repeats:1/real_time 1544885 ns 526298 ns 452 632.759k items/s BM_ThreadedTaskGroup/threads:1/task_cost:100000/repeats:1/real_time 9506192 ns 53110 ns 69 10.3756k items/s BM_ThreadedTaskGroup/threads:2/task_cost:100000/repeats:1/real_time 5262119 ns 67967 ns 116 18.7439k items/s BM_ThreadedTaskGroup/threads:4/task_cost:100000/repeats:1/real_time 2710626 ns 82870 ns 252 36.3875k items/s BM_ThreadedTaskGroup/threads:8/task_cost:100000/repeats:1/real_time 1602394 ns 65768 ns 423 61.5534k items/s ``` Author: Antoine Pitrou <antoine@python.org> Closes #3337 from pitrou/ARROW-4177-thread-pool-benchmark and squashes the following commits: 5a17ca0d8 <Antoine Pitrou> Fix warnings 2ffce8376 <Antoine Pitrou> Make ThreadedTaskGroup mostly lockless (apart from ThreadPool) b5260b955 <Antoine Pitrou> ARROW-4177: Add ThreadPool and TaskGroup microbenchmarks