Skip to content

refactor(server): replace goto with structured control flow in get_global_vram_usage_pct() #2

Description

@jane-alesi

Problem

src/cpp/server/system_info.cpp::get_global_vram_usage_pct() uses two goto labels (try_nvidia, try_amd) for early-exit flow control. While valid C++, this is a code smell and makes the logic harder to follow and modify.

Proposed Solution

Replace the goto-based flow with flag-based early exit (e.g., bool tried_nvidia = false; bool has_kfd = ...;). Restructure as:

// Step 1: NVIDIA path (always attempted)
// Step 2: AMD sysfs path (early-exit via KFD + PCI vendor check if no NVIDIA GPU exists)
// Step 3: Return best ratio found

This matches the existing style elsewhere in the codebase and improves readability without changing behavior.

Scope

  • src/cpp/server/system_info.cpp only -- ~50 lines of logic restructure, zero behavioral change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions