Skip to content

Avoid is_coroutine_function calls in Server #4469

Description

@mrocklin

We currently support handlers that are either synchronous or asynchronous

handler = self.stream_handlers[op]
if is_coroutine_function(handler):
self.loop.add_callback(handler, **merge(extra, msg))
await gen.sleep(0)
else:
handler(**merge(extra, msg))

In #4443 we learned that these checks take up some time. In a recent run it takes 100ms out of about a 2.5s run, so around 4%

There are a couple of ways to address this:

  1. We can try to find some other cheaper check
  2. We can make all of our handlers async def functions and asyncify the entire codebase (we should also check that this doesn't incur other costs if so)

cc @dask/scheduler-performance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions