Skip to content

Conversation

@crusaderky
Copy link
Collaborator

@crusaderky crusaderky commented Feb 3, 2021

Changes to HighLevelGraph:

  • Order-of-magnitude speedup of __getitem__ in the most common use cases
  • various minor speedups thanks to set arithmetics
  • type annotations to declare layers, dependencies, and all other internal collections as read-only
  • copy() now also copies the memoized data of get_all_dependencies()
  • new method to_dict(), which is a memoized wrapper around ensure_dict()
  • keys(), items(), and values() are now memoized. The extra RAM usage compared to the previous design should be trivial (I replaced a set with a dict where all the values are already referenced objects)
  • keys(), items(), and values() now respect the Mapping protocol and are respectively KeysView, ItemsView and ValuesView instead of lists
  • deprecated keyset()
  • 50x speedup in keys(), items(), values(), upstream of memoization:
import dask.array as da 
a = da.random.randint(0, 10, size=10_000, chunks=10) 
# Create more layers for HighLevelGraph 
for i in range(10): 
    a = a + 1


def bench(k):
    try:
        del a._to_dict
    except AttributeError:
        pass
    list(getattr(a.dask, k)())

%timeit bench("keys")
%timeit bench("values")  
%timeit bench("items")  

Before:

3.19 ms ± 8.28 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
3.2 ms ± 5.39 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
3.1 ms ± 46.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

After:

57.1 µs ± 493 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
58.1 µs ± 152 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
243 µs ± 1.16 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

This iterates upon #4918.

crusaderky added a commit to crusaderky/dask that referenced this pull request Feb 3, 2021
@crusaderky crusaderky closed this Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant