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

Track worker_state_machine.TaskState instances #6525

Merged
merged 14 commits into from Jun 16, 2022

Conversation

hendrikmakait
Copy link
Member

@hendrikmakait hendrikmakait commented Jun 8, 2022

Partially addresses #6250

  • Tests added / passed
  • Passes pre-commit run --all-files

Comment on lines 44 to 50
def test_task_state_tracking():
x = TaskState("x")
assert len(TaskState._instances) == 1
assert first(TaskState._instances) == x

del x
assert len(TaskState._instances) == 0
Copy link
Member

Choose a reason for hiding this comment

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

You should add the clean ctxmanager or just the clean_instances ctxmanager. I don't think this is applied automatically and this test would otherwise be fragile and dependent on test order

@hendrikmakait hendrikmakait marked this pull request as ready for review June 8, 2022 10:17
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2022

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       15 files  ±  0         15 suites  ±0   6h 26m 53s ⏱️ + 12m 59s
  2 856 tests +  3    2 774 ✔️ +  4    81 💤 ±0  1  - 1 
21 158 runs  +21  20 212 ✔️ +25  945 💤  - 3  1  - 1 

For more details on these failures, see this check.

Results for commit 748dc48. ± Comparison against base commit a1840bb.

♻️ This comment has been updated with latest results.

@hendrikmakait
Copy link
Member Author

The new flake #6530 might be related, not sure.

Comment on lines +240 to +241
def __post_init__(self):
TaskState._instances.add(self)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't work on unpickle.

Suggested change
def __post_init__(self):
TaskState._instances.add(self)
def __new__(cls, *args, **kwargs):
TaskState._instances.add(self)
return object.__new__(cls)

+ unit test for pickle/unpickle round trip

Copy link
Member

Choose a reason for hiding this comment

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

We're not pickling TaskState objects anywhere, are we?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We aren't today, but that's not an excuse to have it future-proofed. Namely it would make a lot of sense to pickle dump our new WorkerState class and everything it contains.

Copy link
Member

Choose a reason for hiding this comment

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

Well, the "excuse" is scope creep.

Using new as in

    def __new__(cls, *args, **kwargs):
        inst = object.__new__(cls)
        TaskState._instances.add(inst)
        return inst

does not work because we're defining the hash function as the hash of the key, i.e. we can only add fully initialized TaskState objects to the weakref.

Apart from this, we actually can (un-)pickle this class but will simply not add the instance to this weakset. For the only purpose of dumping this (like in our cluster dump) this is absolutely sufficient.
At this point and for this functionality I'm not willing to reconsider the hash function

@fjetter fjetter force-pushed the track-worker-task-state-instances branch from ea0281d to 7be8d35 Compare June 15, 2022 12:01
@github-actions
Copy link
Contributor

github-actions bot commented Jun 15, 2022

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       15 files  ±  0         15 suites  ±0   6h 35m 33s ⏱️ - 31m 32s
  2 870 tests +  2    2 790 ✔️ +33    80 💤 ±0  0  - 28 
21 259 runs  +14  20 322 ✔️ +50  937 💤  - 2  0  - 31 

Results for commit 1edbb34. ± Comparison against base commit cb88e3b.

♻️ This comment has been updated with latest results.

@fjetter fjetter force-pushed the track-worker-task-state-instances branch from 7be8d35 to 1edbb34 Compare June 15, 2022 13:49
@fjetter fjetter linked an issue Jun 15, 2022 that may be closed by this pull request
3 tasks
@fjetter fjetter merged commit 52b0b26 into dask:main Jun 16, 2022
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.

Ensure TaskState instances are released on Scheduler and Worker
3 participants