Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotation of some comm related methods in the Scheduler #4341

Merged
merged 12 commits into from
Dec 10, 2020

Conversation

jakirkham
Copy link
Member

This does some annotation around comm related methods in the scheduler: report_on_key, report, and worker_send. Should help speed through the intermediate code needed to send out a message.

Provides type annotation for `stream_comms` in the form of a locally
stored variable in `worker_send`. This should allow the Python C API to
used for lookups when the scheduler is Cythonized.
Instead of checking for `"key"` in `msg`, just use `.get(...)` to try
and retrieve the `key`. If it fails, we get `None`, which we can check
and ignore quickly. If not, we get the value and can proceed to use it.
Should avoid needing to check for the presence of `"key"` in `msg`
twice.
Should allow more efficient access of `tasks` in Cython as it is known
to be a `dict`.
Should allow more efficient access of `client_comms` in Cython as it is
known to be a `dict`.
This ends up being a bit faster than catching the error (especially in
Cython/C where it knows this error can just be cleared instead of
handled). Plus the comparison to `None` is fast in both (in Cython/C
this is a simple pointer value comparison similar to comparing to
`NULL`).
Should allow more efficient access of `tasks` in Cython as it is known
to be a `dict`.
This ends up being a bit faster than catching the error (especially in
Cython/C where it knows this error can just be cleared instead of
handled). Plus the comparison to `None` is fast in both (in Cython/C
this is a simple pointer value comparison similar to comparing to
`NULL`).
@@ -4201,7 +4201,7 @@ def update_data(
self.client_desires_keys(keys=list(who_has), client=client)

def report_on_key(self, key: str = None, ts: TaskState = None, client: str = None):
assert (key is None) + (ts is None) == 1, (key, ts)
assert (key is None) != (ts is None), (key, ts)
Copy link
Member Author

Choose a reason for hiding this comment

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

Found another case in the scheduler like this, addressing in PR ( #4342 ).

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