Skip to content

Comments

Fix Total CPU % on /workers tab to normalize by total nthreads#9195

Open
ernestprovo23 wants to merge 2 commits intodask:mainfrom
ernestprovo23:fix/issue-8490-total-cpu-percent
Open

Fix Total CPU % on /workers tab to normalize by total nthreads#9195
ernestprovo23 wants to merge 2 commits intodask:mainfrom
ernestprovo23:fix/issue-8490-total-cpu-percent

Conversation

@ernestprovo23
Copy link

Closes #8490

The WorkerTable's Total CPU % calculation divided by len(workers) instead of sum(nthreads), producing incorrect values when workers have multiple threads (e.g., a 2-worker cluster with 8 threads each, one maxed out, showed 400% instead of 50%).

This one-line fix aligns the cpu column with the already-correct cpu_fraction column by using sum(ws.nthreads) as the divisor. Same fix pattern as PR #3897, which corrected the identical bug for memory_percent.

  • Tests added / passed
  • Passes pre-commit run --all-files

The WorkerTable's Total CPU % divided by len(workers) instead of
sum(nthreads), producing incorrect values when workers have multiple
threads (e.g., 400% instead of 50%). This aligns the "cpu" column
with the already-correct "cpu_fraction" column, matching the same
fix pattern as PR dask#3897 for memory_percent.

Closes dask#8490
@ernestprovo23
Copy link
Author

All tests pass across Python 3.10–3.14 on Ubuntu and macOS, and the codecov/patch check confirms the new code has adequate test coverage.

The codecov/project failure appears to be a project-wide coverage threshold issue unrelated to this PR's changes (1 line fix + 1 new test assertion).

Happy to add additional test coverage if needed — just let me know.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 22, 2026

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    31 files  ±0      31 suites  ±0   11h 5m 53s ⏱️ - 4m 19s
 4 113 tests ±0   4 007 ✅ ±0    104 💤 ±0  2 ❌ ±0 
59 636 runs  ±0  57 159 ✅  - 1  2 474 💤 ±0  3 ❌ +1 

For more details on these failures, see this check.

Results for commit 7975318. ± Comparison against base commit 4fb4814.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@crusaderky crusaderky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it deeply confusing to have cpu go up to 100% on the total and to 400% on the individual workers. On the other hand, as #8490 (comment) points out, changing the individual workers' reading from 0%~400% to 0%~100% would cause more confusion and make the board less useful.

I think I would be inclined to merge if it was shown as a pure number showing the total number of cores used.

So for a 20-workers cluster with 4 CPUs each,

  • each worker would continue ranging between 0% and 400% (as it is something users are used to see on any PC),
  • while the total would go from 0 to 80 (instead of 8000% like in the comment #8490 (comment)).

Per review feedback: the Total row now displays a raw core count
(e.g. 3.5 = 3.5 cores busy) while per-worker rows keep showing
the familiar 0-400% style. Uses HTMLTemplateFormatter with a
hidden _is_total column for conditional rendering in the same
Bokeh DataTable column.
@ernestprovo23
Copy link
Author

thanks @crusaderky, updated based on your feedback.

total row now shows raw core count (e.g. 3.5 = 3.5 cores busy) instead of a percentage. per-worker rows still show the 0-400% style, unchanged.

used an HTMLTemplateFormatter with a hidden _is_total column to conditionally format in the same bokeh column. tests updated.

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.

Total CPU % on /workers tab makes little sense

2 participants