-
-
Notifications
You must be signed in to change notification settings - Fork 720
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
WIP Gc scheduler taskstate #6246
base: main
Are you sure you want to change the base?
Conversation
# _workers = self.workers | ||
# _events = self.events | ||
# def remove_worker_from_events(): | ||
# # If the worker isn't registered anymore after the delay, remove from events | ||
# if address not in _workers and address in _events: | ||
# del _events[address] | ||
|
||
# cleanup_delay = parse_timedelta( | ||
# dask.config.get("distributed.scheduler.events-cleanup-delay") | ||
# ) | ||
# self.loop.call_later(cleanup_delay, remove_worker_from_events) | ||
# logger.debug("Removed worker %s", ws) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tornado call_later
, add_callback
, etc. things keep a reference around. With the above construction, we can break references to the scheduler but the sets/dicts still include references to WorkerState
instances which themselves hold references to TaskState
objects.
@@ -49,7 +49,6 @@ class SemaphoreExtension: | |||
""" | |||
|
|||
def __init__(self, scheduler): | |||
self.scheduler = scheduler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is obvious but the GC should be able to break this cycle
@@ -3078,7 +3091,7 @@ def __init__( | |||
resources = {} | |||
aliases = {} | |||
|
|||
self._task_state_collections = [unrunnable] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This construction feels a bit off and is a relict of Cython. I will come back to this again once we removed the SchedulerState
I tried introducing a weakref instance check for the TaskState objects as proposed in #6226 (comment)
but I failed because they are actually never GCed.
It is not surprising that our classes are highly interconnected things and I am not at all surprised that we explicitly need to collect but the cycle detection doesn't suffice to release these objects. Turns out, we're leaking a bunch of explicit references all over the place.
Some of these are not obvious and I figured this bit of effort I invested here is worth preserving. I'll comment in-code for a few (to me) surprising things