Skip to content

Offload (de)serialization to a separate thread - #1218

Merged
pitrou merged 2 commits into
dask:masterfrom
pitrou:offload_deserialize
Jun 29, 2017
Merged

pitrou merged 2 commits into
dask:masterfrom
pitrou:offload_deserialize

Conversation

@pitrou

@pitrou pitrou commented Jun 29, 2017

Copy link
Copy Markdown
Member

This is conditioned on the input size, to avoid increasing the overhead of processing
small administrative messages.

This is conditioned on the input size, to avoid increasing the overhead of processing
small administrative messages.
@pitrou pitrou closed this Jun 29, 2017
@pitrou pitrou reopened this Jun 29, 2017

@mrocklin mrocklin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like a nicely simple change. We should try running this through some benchmarks eventually.

Comment thread distributed/comm/utils.py Outdated


def offload(fn, *args, **kwargs):
return _offloader.submit(fn, *args, **kwargs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why the need for the Offloader class here? Would a raw ThreadPoolExecutor work just as well? Is this necessary because of the finalize cleanup code? Does finalize require being part of a class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is no real need, but I find it nice to avoid too many global variables.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're going to have a global _offloader regardless. Adding another for the finalizer doesn't seem that bad to me.

I generally prefer to stick to using common types for things when possible. I personally find it difficult to quickly understand code when it creates many of its own abstractions.

Comment thread distributed/comm/utils.py Outdated
class Offloader(object):

def __init__(self):
self.executor = ThreadPoolExecutor(max_workers=1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We might want a couple of workers here? We do accept multiple messages concurrently. Having multiple threads here might help fast messages get through in the presence of large messages.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, that depends. On the workers, that might overcommit worker threads? (do we care about this issue?)

The problem is we need a heuristic. Something like min(4, cpu_cores())?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In my experience heavy communication and heavy computation rarely overlap. In the case that they do I'd rather have communication take precedence. I think it makes sense to have somewhere between 2-4 communication threads. Although really all of this is probably premature before we find some application that cares.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, having multiple threads early might help expose any potential issues.

@pitrou

pitrou commented Jun 29, 2017 •

Copy link
Copy Markdown
Member Author

(Travis-Ci seems not to trigger any builds from Github anymore)

Edit: it came back

@mrocklin

Copy link
Copy Markdown
Member

This looks good to me. +1.

I ran both a basic small-data benchmark and a more communication heavy benchmark (with chunks > size 10MB) and things seemed about the same.

@pitrou

pitrou commented Jun 29, 2017

Copy link
Copy Markdown
Member Author

Thank you. I'm merging now.

@pitrou
pitrou merged commit 67abe7e into dask:master Jun 29, 2017
@pitrou
pitrou deleted the offload_deserialize branch June 29, 2017 17:08
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.

2 participants