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

Avoid excessive attribute access overhead for remove_from_task_prefix_count #8821

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,17 +775,20 @@ def remove_from_processing(self, ts: TaskState) -> None:
self._dec_needs_replica(dts)

def _remove_from_task_prefix_count(self, ts: TaskState) -> None:
count = self.task_prefix_count[ts.prefix.name] - 1
prefix_name = ts.prefix.name
count = self.task_prefix_count[prefix_name] - 1
tp_count = self.task_prefix_count
tp_count_global = self.scheduler._task_prefix_count_global
if count:
self.task_prefix_count[ts.prefix.name] = count
tp_count[prefix_name] = count
else:
del self.task_prefix_count[ts.prefix.name]
del tp_count[prefix_name]

count = self.scheduler._task_prefix_count_global[ts.prefix.name] - 1
count = tp_count_global[prefix_name] - 1
if count:
self.scheduler._task_prefix_count_global[ts.prefix.name] = count
tp_count_global[prefix_name] = count
else:
del self.scheduler._task_prefix_count_global[ts.prefix.name]
del tp_count_global[prefix_name]

def remove_replica(self, ts: TaskState) -> None:
"""The worker no longer has a task in memory"""
Expand Down
Loading