Skip to content

Process CPU usage reports exactly double (200% per core) due to sysinfo refresh rate desync #4

Description

@joespinstheglobe

Description:
When running a single-threaded CPU load on an Orange Pi 5 Ultra (RK3588) on vendor distro of Ubuntu Jammy 6.1, the rktop process list reports the application using 200% CPU, even though the CPU core panel correctly shows 100% usage.

Steps to Reproduce:

Open rktop.

Run a single-threaded benchmark (e.g., xz -z9k testfile).

Note that the CPU core hits 100%, but the process list shows xz running at 200%.
Running an 8-thread workload [xz -T8 testfile] shows exactly 800%, which masks the bug. Presumably this is because it hits the sysinfo crate's max_cores * 100 ceiling.

Root Cause:
The issue stems from a time-desync in the sysinfo crate polling, caused by the RefreshConfig defaults in main.rs.
Currently, sys.refresh_cpu_all() runs every 1 second, but sys.refresh_processes() runs every 2 seconds. Because of how sysinfo calculates CPU deltas, it evaluates 2 seconds of process execution against a 1-second global time window, acting as an unintended 2x multiplier (2s of work / 1s time window * 100 = 200%).

The Fix:
Synchronizing the refresh rates in main.rs fixes the math and accurately reports 100% per core.

// main.rs - Line 34
struct RefreshConfig {
    cpu_memory: 2,    //  changed to 2 to sync with processes
    network_disk: 2,  // Network and disk I/O
    processes: 2,     
    #[allow(dead_code)]
    stats: 5,         // Governor, TCP connections, etc.
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions