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

[Client] Make Client_Hook per-thread #16731

Merged
merged 6 commits into from
Jun 30, 2021

Conversation

ijrsvt
Copy link
Contributor

@ijrsvt ijrsvt commented Jun 29, 2021

Why are these changes needed?

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@amogkam
Copy link
Contributor

amogkam commented Jun 29, 2021

I think this should resolve #16743 as well cc @matthewdeng

@ijrsvt
Copy link
Contributor Author

ijrsvt commented Jun 30, 2021

Ugh, the test issues from earlier were due to my erroneous use of _explicitly_enable_client_mode which leaked state for the rest of test sessions :'(

I added a comment that _explicitly_enable_client_mode should be avoided in tests.

return out


def _explicitly_enable_client_mode():
"""Force client mode to be enabled.
NOTE: This should not be used in tests, use `enable_client_mode`.
"""
global client_mode_enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between client mode enabled and client hook enabled?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think "client mode enabled" is a global setting saying whether ray client is enabled and "client hook enabled" is an internal toggle used by the code to turn on/off delegating ray apis to the client stub.

It could help to add a comment explaining the meanings to this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep as @DmitriGekhtman said.

I added two comments explaining these!!

I also renamed them:

  • client_mode_enabled -> is_client_mode_enabled (making it clear that this is answering the question of 'is client mode currently enabled'.
  • client_hook_enabled -> _client_hook_status_on_thread (making it clear that it is thread specific).

def _get_client_hook_enabled():
global _client_hook_enabled
if not hasattr(_client_hook_enabled, "val"):
_client_hook_enabled.val = True
Copy link
Contributor

@DmitriGekhtman DmitriGekhtman Jun 30, 2021

Choose a reason for hiding this comment

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

Just curious - is this right: when you start a new thread, its copy of _client_hook_enabled doesn't have val set, hence the need for this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DmitriGekhtman
Copy link
Contributor

liiiint

@ijrsvt
Copy link
Contributor Author

ijrsvt commented Jun 30, 2021

liiiint

Hmmm, I knew it was too good to be true when local formatting didn't do anything 😆

@ijrsvt ijrsvt merged commit 1f14f36 into ray-project:master Jun 30, 2021
@ijrsvt ijrsvt deleted the make-client-thread-safe branch June 30, 2021 18:48
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.

[Dask] dask_shuffle_optimization fails with Client mode
5 participants