Skip to content

Commit 1631b6a

Browse files
authored
Add a Dask benchmark (gh-246)
The Dask scheduler is largely pure-python-code-bound. There is a discussion about the details here. For this reason, it makes a good real-world workload of a distributed system benchmark (even when the benchmark is running locally on a single core). Thanks to @TomAugspurger for the suggestion, and @mrocklin for providing the meat of the benchmark itself.
1 parent 4b317cb commit 1631b6a

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

pyperformance/data-files/benchmarks/MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ generators <local>
1414
chameleon <local>
1515
chaos <local>
1616
crypto_pyaes <local>
17+
dask <local>
1718
deepcopy <local>
1819
deltablue <local>
1920
django_template <local>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[project]
2+
name = "pyperformance_bm_dask"
3+
requires-python = ">=3.8"
4+
dependencies = ["pyperf"]
5+
urls = {repository = "https://github.com/python/pyperformance"}
6+
dynamic = ["version"]
7+
8+
[tool.pyperformance]
9+
name = "dask"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dask[distributed]==2022.2.0
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Benchmark the Dask scheduler running a large number of simple jobs.
3+
4+
Author: Matt Rocklin, Michael Droettboom
5+
"""
6+
7+
from dask.distributed import Client, Worker, Scheduler, wait
8+
9+
import pyperf
10+
11+
12+
def inc(x):
13+
return x + 1
14+
15+
16+
async def benchmark():
17+
async with Scheduler() as scheduler:
18+
async with Worker(scheduler.address):
19+
async with Client(scheduler.address, asynchronous=True) as client:
20+
21+
futures = client.map(inc, range(100))
22+
for _ in range(10):
23+
futures = client.map(inc, futures)
24+
25+
await wait(futures)
26+
27+
28+
if __name__ == "__main__":
29+
runner = pyperf.Runner()
30+
runner.metadata['description'] = "Benchmark dask"
31+
runner.bench_async_func('dask', benchmark)

0 commit comments

Comments
 (0)