Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Jul 27, 2023
1 parent bd4069a commit 2da9df9
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions distributed/scheduler.py
Expand Up @@ -8063,21 +8063,15 @@ def adaptive_target(self, target_duration=None):
target_duration = parse_timedelta(target_duration)

# CPU
queued = take(100, concat([self.queued, self.unrunnable]))
queued_occupancy = 0
for ts in queued:
if ts.prefix.duration_average == -1:
queued_occupancy += self.UNKNOWN_TASK_DURATION
else:
queued_occupancy += ts.prefix.duration_average

if len(self.queued) + len(self.unrunnable) < 100:
queued_occupancy = 0
for ts in concat([self.queued, self.unrunnable]):
if ts.prefix.duration_average == -1:
queued_occupancy += self.UNKNOWN_TASK_DURATION
else:
queued_occupancy += ts.prefix.duration_average
else:
queued_occupancy = 0
for ts in take(100, concat([self.queued, self.unrunnable])):
if ts.prefix.duration_average == -1:
queued_occupancy += self.UNKNOWN_TASK_DURATION
else:
queued_occupancy += ts.prefix.duration_average
if len(self.queued) + len(self.unrunnable) > 100:
queued_occupancy *= (len(self.queued) + len(self.unrunnable)) / 100

Check warning on line 8075 in distributed/scheduler.py

View check run for this annotation

Codecov / codecov/patch

distributed/scheduler.py#L8075

Added line #L8075 was not covered by tests

cpu = math.ceil(
Expand Down

0 comments on commit 2da9df9

Please sign in to comment.