Skip to content

Fix CPU panel GPU sub-graph widths (crash / dropped sub-graphs)#1614

Open
stepelu wants to merge 1 commit intoaristocratos:mainfrom
stepelu:fix/gpu-subgraph-widths
Open

Fix CPU panel GPU sub-graph widths (crash / dropped sub-graphs)#1614
stepelu wants to merge 1 commit intoaristocratos:mainfrom
stepelu:fix/gpu-subgraph-widths

Conversation

@stepelu
Copy link
Copy Markdown

@stepelu stepelu commented Apr 17, 2026

Corrects the arithmetic in init_graphs() that sized per-GPU gpu-totals sub-graphs in the CPU panel, and adds a Draw::Graph backstop for non-positive widths.

Addresses: #874, #1017, #1118, #742, #949

init_graphs() for the `gpu-totals` field used an arithmetically
incorrect per-sub-graph width formula. For gpu_draw_count >= 4 the
computed width was too small; for the final graph at
gpu_draw_count == 8 on a narrow panel it went negative, causing
Graph::Graph() to pass a bogus data_offset into Graph::_create()
whose `data.size() - data_offset > 1` check wraps under unsigned
arithmetic and triggers

    deque::_M_range_check: __n (which is 13) >= this->size() (which is 2)

(or `basic_string::at: ...` on older stdlib).

Replace the formula with a uniform split that gives every sub-graph
`(graph_default_width - (gpu_draw_count - 1)) / gpu_draw_count` cells.
At most `gpu_draw_count - 1` cells remain as an unused strip at the
right edge; sub-graph widths and label positioning are then uniform.

Also guard Graph::Graph() and Graph::operator()() against non-positive
widths as a backstop for any other caller with a bad width.

Addresses: aristocratos#874, aristocratos#1017, aristocratos#1118, aristocratos#742, aristocratos#949
@deckstose deckstose self-requested a review April 17, 2026 10:03
@stepelu
Copy link
Copy Markdown
Author

stepelu commented Apr 20, 2026

The failing checks don’t look related to this PR’s changes (only touches src/btop_draw.cpp). CI is blocked by the snap build environment / snap/snapcraft.yaml dependency list (likely the gcc-14 / g++-14 pin).

@apaz-cli
Copy link
Copy Markdown

I am hyped by this PR, I have been upset that btop does not work well on H100 nodes with tons of cpu cores.

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.

2 participants