I use dask to parallelize some processing, which is quite a joy.
I have an case, where the calculation on the client side requires some lookup data that is quite heavy to generate, so scatter these data to the clients:
[future_dict] = client.scatter([large_dict], broadcast=True)
The calculation is then something like
def worker(i):
key = do_some_work()
data = future_dict.result()[key]
res = do_some_more_work( data )
return (i, res )
f = client.map( worker, range(200))
res = client.gather( f )
This works, but the lookup future_dict.result()[key] is quite slow. The time it takes to do the lookup in the worker is similar to unpickl'ing a pickled version of large_dict, so I guess my dictionary de-serialized in each worker.
Can I do anything to make access to scattered data faster? Eg if my hypothesis of the data being de-serialized in each worker is correct, can I the do something to make the de-serialization happen once in each client only?