Skip to content

Conversation

@fjetter
Copy link
Member

@fjetter fjetter commented Apr 29, 2022

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

Comment on lines +4400 to +4411
# _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)
Copy link
Member Author

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.

"""

def __init__(self, scheduler):
self.scheduler = scheduler
Copy link
Member Author

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

resources = {}
aliases = {}

self._task_state_collections = [unrunnable]
Copy link
Member Author

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

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.

1 participant