-
-
Notifications
You must be signed in to change notification settings - Fork 750
Reduce size of scheduler_info #9045
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
Changes from all commits
3bc4ec4
41dd231
f45e119
123d7fd
665431f
41ce938
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1654,6 +1654,8 @@ class SchedulerState: | |
| idle_task_count: set[WorkerState] | ||
| #: Workers that are fully utilized. May include non-running workers. | ||
| saturated: set[WorkerState] | ||
| #: Current total memory across all workers (sum over memory_limit) | ||
| total_memory: int | ||
| #: Current number of threads across all workers | ||
| total_nthreads: int | ||
| #: History of number of threads | ||
|
|
@@ -1778,6 +1780,7 @@ def __init__( | |
| self.task_groups = {} | ||
| self.task_prefixes = {} | ||
| self.task_metadata = {} | ||
| self.total_memory = 0 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's almost overkill to maintain additional state for this but if we have to call
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I'm surprised we are not tracking this already. Seems like a useful metric for adaptive scaling or smth like that 🤷 |
||
| self.total_nthreads = 0 | ||
| self.total_nthreads_history = [(time(), 0)] | ||
| self.queued = queued | ||
|
|
@@ -4075,16 +4078,22 @@ def _repr_html_(self) -> str: | |
| tasks=self.tasks, | ||
| ) | ||
|
|
||
| def identity(self) -> dict[str, Any]: | ||
| def identity(self, n_workers: int = -1) -> dict[str, Any]: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the default of -1 is to maintain backwards compat (no idea who is calling this in the wild). All callers in this code base are setting this explicitly |
||
| """Basic information about ourselves and our cluster""" | ||
| if n_workers == -1: | ||
| n_workers = len(self.workers) | ||
| d = { | ||
| "type": type(self).__name__, | ||
| "id": str(self.id), | ||
| "address": self.address, | ||
| "services": {key: v.port for (key, v) in self.services.items()}, | ||
| "started": self.time_started, | ||
| "n_workers": len(self.workers), | ||
| "total_threads": self.total_nthreads, | ||
| "total_memory": self.total_memory, | ||
| "workers": { | ||
| worker.address: worker.identity() for worker in self.workers.values() | ||
| worker.address: worker.identity() | ||
| for worker in itertools.islice(self.workers.values(), n_workers) | ||
| }, | ||
| } | ||
| return d | ||
|
|
@@ -4535,6 +4544,7 @@ async def add_worker( | |
| dh_addresses.add(address) | ||
| dh["nthreads"] += nthreads | ||
|
|
||
| self.total_memory += ws.memory_limit | ||
| self.total_nthreads += nthreads | ||
| self.total_nthreads_history.append((time(), self.total_nthreads)) | ||
| self.aliases[name] = address | ||
|
|
@@ -5446,6 +5456,7 @@ async def remove_worker( | |
| dh_addresses: set = dh["addresses"] | ||
| dh_addresses.remove(address) | ||
| dh["nthreads"] -= ws.nthreads | ||
| self.total_memory -= ws.memory_limit | ||
| self.total_nthreads -= ws.nthreads | ||
| self.total_nthreads_history.append((time(), self.total_nthreads)) | ||
| if not dh_addresses: | ||
|
|
||
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.
Using n_workers=0 in this context results in an empty workers list. If the intention is to provide a default view for diagnostics, consider using a value such as -1 (to fetch all) or the same default limit (e.g. 5) used elsewhere.
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.
that's intentional since the workers info is not even accessed here