Created
February 22, 2019 10:30
-
-
Save pierreglaser/26207c20dd8526d6df7963044a3e4477 to your computer and use it in GitHub Desktop.
Use c pickler extension to communicate data to workers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import loky | |
def process_dict(x): | |
return len(x) | |
if __name__ == "__main__": | |
e = loky.get_reusable_executor(max_workers=2) | |
large_dict = dict(zip(range(500000), range(500000))) | |
t0 = time.time() | |
e.submit(process_dict, large_dict).result() | |
total_time = round(time.time() - t0, 3) | |
print(f'total time: {total_time}s') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using current
cloudpickle
:using a
cloudpickle
that extends the C pickler:We observe a 15x speedup here, but there is an irreductible startup time of 0.15 seconds (time required to send a negligable amount of data). If we subtract his startup time, we are talking about a x30 speedup here.