Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a benchmark for take #1519

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/benchmarks/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dask.array as da
import numpy as np
import pytest
from dask.core import flatten
from dask.utils import parse_bytes

from ..utils_test import (
Expand Down Expand Up @@ -257,3 +258,29 @@ def test_map_overlap_sample(small_client, new_array):
x = new_array((10000, 10000), chunks=(50, 50)) # 40_000 19.5 kiB chunks
y = x.map_overlap(lambda x: x, depth=1)
y[5000:5010, 5000:5010].compute()


def _create_indexer(n, chunk_n):
idx = np.arange(0, n)
np.random.shuffle(idx[: n // 10])

indexer = []
for i in range(0, n, chunk_n):
indexer.append(idx[i : i + chunk_n].tolist())
return indexer


def test_take(small_client, new_array):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test based on some real-world use case? If so, some context would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the smallest thing that the current implementation can still handle in reasonable time... everything bigger blows up

n = 2000
chunk_n = 250
x = new_array((n, n, n), chunks=(chunk_n, chunk_n, chunk_n))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Annotating some data sizes would be interesting.

indexer = list(flatten(_create_indexer(n, chunk_n)))
x[:, indexer, :].sum().compute()


# def test_shuffle(small_client, new_array):
# n = 2000
# chunk_n = 250
# x = new_array((n, n, n), chunks=(chunk_n, chunk_n, chunk_n))
# indexer = _create_indexer(n, chunk_n)
# x.shuffle(indexer, axis=1).sum().compute()
Comment on lines +280 to +286
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# def test_shuffle(small_client, new_array):
# n = 2000
# chunk_n = 250
# x = new_array((n, n, n), chunks=(chunk_n, chunk_n, chunk_n))
# indexer = _create_indexer(n, chunk_n)
# x.shuffle(indexer, axis=1).sum().compute()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have converted to draft, I don't want to merge this before shuffle is available

Loading