Skip to content

Commit

Permalink
avoid excessive attribute access overhead for remove_from_task_prefix…
Browse files Browse the repository at this point in the history
…_count
  • Loading branch information
fjetter committed Aug 7, 2024
1 parent 92fc0e2 commit 702784b
Showing 1 changed file with 9 additions and 6 deletions.
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

0 comments on commit 702784b

Please sign in to comment.