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

Yank state machine out of Worker class #6476

Closed
Tracked by #5736
crusaderky opened this issue May 30, 2022 · 5 comments · Fixed by #6410, #6475, #6474, #6512 or #6564
Closed
Tracked by #5736

Yank state machine out of Worker class #6476

crusaderky opened this issue May 30, 2022 · 5 comments · Fixed by #6410, #6475, #6474, #6512 or #6564
Assignees

Comments

@crusaderky
Copy link
Collaborator

crusaderky commented May 30, 2022

This issue is a tracker for the worker state machine refactor, as described in the wider epic #5736.

In scope for this issue is to yank out all state machine logic from Worker and create two new classes, WorkerState and BaseWorker.

Writing additional unit tests, beyond tweaking the already existing ones, is out of scope.

Contributing PRs:

@crusaderky crusaderky self-assigned this May 30, 2022
@crusaderky crusaderky reopened this Jun 1, 2022
@crusaderky crusaderky reopened this Jun 2, 2022
@crusaderky crusaderky linked a pull request Jun 6, 2022 that will close this issue
@crusaderky crusaderky reopened this Jun 7, 2022
@fjetter fjetter reopened this Jun 7, 2022
@fjetter
Copy link
Member

fjetter commented Jun 7, 2022

apparently blocks also acts as a "please close ticket" keyword 🤔

@zklaus
Copy link

zklaus commented Jun 7, 2022

Just wanted to leave some words of gratitude and encouragement. It's great to see this move forward; memory leaks and deadlocks due to worker transitions have become a real problem in our production code lately, so your work on this is greatly appreciated!

@crusaderky
Copy link
Collaborator Author

I'll have to move _notify_plugins from Worker to WorkerState and I'll have to share the Worker.plugins dict by reference with WorkerState. This is because of

self._notify_plugins("transition", ts.key, start, finish, **kwargs)

@fjetter were you expecting this? Do you have an alternative design in mind?

@crusaderky
Copy link
Collaborator Author

crusaderky commented Jun 9, 2022

I'm going to apply the following changes to methods and attributes of Worker. This will potentially break third party code that directly interact with (what we believe is) internal API.
Please review and speak up if you see any issues.

  • These attributes will be shared by reference between Worker and WorkerState, like it already happens for WorkerMemoryManager:

    • data
    • plugins
    • tasks
  • These methods will move from Worker to Worker.state and will become private, with no deprecation cycle:

    • transitions()
    • transition_<begin>_<finish>()
    • ensure_task_exists()
    • validate_task_<state>()
  • These attributes and methods will move from Worker to Worker.state, with an accessor in Worker which will raise a DeprecationWarning:

    • tasks
    • log
    • stimulus_log
    • story()
    • stimulus_story()
    • total_out_connections
    • comm_threshold_bytes
    • data_needed
    • data_needed_per_worker
    • ready
    • constrained
    • executing_count
    • executed_count
    • long_running
    • has_what
    • in_flight_tasks
    • in_flight_workers
    • busy_workers
    • waiting_for_data_count
    • generation
    • target_message_size
    • transition_counter
    • transition_counter_max
    • available_resources
    • _missing_dep_flight
    • _executing
    • executing_count property
    • _in_flight_tasks
    • in_flight_tasks property
    • validate_task()

@fjetter
Copy link
Member

fjetter commented Jun 9, 2022

This list looks good to me.

@crusaderky crusaderky reopened this Jun 13, 2022
@crusaderky crusaderky reopened this Jun 14, 2022
@crusaderky crusaderky linked a pull request Jun 15, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment