Skip to content
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

101% CPU utilization #345

Open
davidak opened this issue Feb 16, 2023 · 9 comments
Open

101% CPU utilization #345

davidak opened this issue Feb 16, 2023 · 9 comments

Comments

@davidak
Copy link

davidak commented Feb 16, 2023

Screenshot from 2023-02-16 16-31-03

The number seem wrong. See the individual cores!

It cycles between 99%, 100% and 101%.


Monitor 0.15.1
NixOS 22.11.2568.c43f676c938

@stsdc
Copy link
Member

stsdc commented Feb 16, 2023

@davidak
Copy link
Author

davidak commented Feb 16, 2023

Rounding issue sounds likely.

Do you need more information to solve it, like the cpu.user + cpu.sys + cpu.nice + cpu.irq + cpu.softirq from top?

@stsdc
Copy link
Member

stsdc commented Feb 16, 2023

Would be nice to have, just in case of.

@davidak
Copy link
Author

davidak commented Feb 20, 2023

top is running with top -1 -d 0.1 and monitor updates every 1s. It could be an issue that they are not in sync.

Here are 3 screenshots:

Screenshot from 2023-02-20 03-26-22
Screenshot from 2023-02-20 03-26-09
Screenshot from 2023-02-20 03-24-15

Here is a video. Maybe it helps to check it frame-by-frame with like VLC: https://www.youtube.com/watch?v=sW3jGuMZOgI
It might stutter a bit since the system was 100% used while also recording.

@stsdc
Copy link
Member

stsdc commented Feb 23, 2023

obraz

** (com.github.stsdc.monitor:68837): DEBUG: 21:25:26.790: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:26.791: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:28.701: CPU.vala:26: 0,999381, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:28.702: CPU.vala:26: 0,999381, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:30.812: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:30.812: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:32.722: CPU.vala:26: 0,999379, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:32.723: CPU.vala:26: 0,999379, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:34.767: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:34.767: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:36.751: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:36.751: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:38.809: CPU.vala:26: 0,999375, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:38.809: CPU.vala:26: 0,999375, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:40.712: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:40.713: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:42.709: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:42.710: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:44.725: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:44.726: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:46.710: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:46.710: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:48.683: CPU.vala:26: 0,999370, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:48.684: CPU.vala:26: 0,999370, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:50.710: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:50.710: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:52.727: CPU.vala:26: 1,000000, 100
** (com.github.stsdc.monitor:68837): DEBUG: 21:25:52.729: CPU.vala:26: 1,000000, 100

Can't reproduce on my machine :(

I'm debugging it with this log line:

    public int percentage {
        get {
            debug ("%f, %d", load, ((int) (Math.round (load * 100))));
            return (int) (Math.round (load * 100));
        }
    }

I have prepared a branch for this issue: https://github.com/stsdc/monitor/tree/101-percent
You may checkout and build.

@davidak
Copy link
Author

davidak commented Feb 23, 2023

I tried to build from the commit, but it fails.

building '/nix/store/z5c5afwm2ic9zfypvlk49b8c3v7fczdm-monitor-0.15.1.drv'...
unpacking sources
unpacking source archive /nix/store/7gvkvd8c082niqkkl8dscqg5imgjk5a0-source
source root is source
patching sources
patching script interpreter paths in meson/post_install.py
meson/post_install.py: interpreter directive changed from "#!/usr/bin/env python3" to "/nix/store/0pyymzxf7n0fzpaqnvwv92ab72v3jq8d-python3-3.10.9/bin/python3"
configuring
meson flags: --buildtype=plain         --libdir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/lib --libexecdir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/libexec         --bindir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/bin --sbindir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/sbin         --includedir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/include         --mandir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/share/man --infodir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/share/info         --localedir=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1/share/locale         -Dauto_features=enabled         -Dwrap_mode=nodownload         --prefix=/nix/store/ckbp5xhv63amjbswv6a1wvjaisb8fnqr-monitor-0.15.1 -Dindicator-wingpanel=enabled 
The Meson build system
Version: 1.0.0
Source dir: /build/source
Build dir: /build/source/build
Build type: native build
Project name: com.github.stsdc.monitor
Project version: 0.15.1
C compiler for the host machine: gcc (gcc 12.2.0 "gcc (GCC) 12.2.0")
C linker for the host machine: gcc ld.bfd 2.40
Vala compiler for the host machine: valac (valac 0.56.3)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program sassc found: YES (/nix/store/crcqig751q842br0rrivir6fv74yd9fq-sassc-3.6.2/bin/sassc)

meson.build:20:0: ERROR: Subproject exists but has no meson.build file

Same error also at previous commit (7786ca3).

Package source changed with:

{ config, pkgs, lib, ... }:

let
  unstable = import <nixos-unstable> { config.allowUnfree = true;
  overlays = [ (
    self: super:
      {
        monitor = super.monitor.overrideAttrs (old: {
          src = super.fetchFromGitHub {
            owner = "stsdc";
            repo = "monitor";
            # for debugging https://github.com/stsdc/monitor/commit/9475ebfdc569020886686cca5991a59458c204bb
            rev = "9475ebf";
            hash = "sha256-mdle+i80WoajZ9GHxsSJbPcuKcAi2Vm3Uf3xjbFQLMA=";
          };
        });
      })
    ];
  };

in
{

...

  environment.systemPackages = with pkgs; [
    unstable.monitor
  ];

}

@stsdc
Copy link
Member

stsdc commented Feb 24, 2023

I'm not familiar with NixOS, can't help with packaging. But maybe you can just clone the repo and try to build from sources?

@davidak
Copy link
Author

davidak commented Feb 25, 2023

The issue was that the repo was not cloned with submodules.

https://gitlab.gnome.org/GNOME/glib/-/issues/2716

@davidak
Copy link
Author

davidak commented Feb 25, 2023

Here are the results:

You should be able to reproduce the issue with: stress-ng --cpu 8 (number of cpu cores)

** (com.github.stsdc.monitor:1544884): DEBUG: 13:27:49.249: CPU.vala:120: us 70418957, sy 8669191, ni 102484, id 108252248
** (com.github.stsdc.monitor:1544884): DEBUG: 13:27:49.249: CPU.vala:125: diff_used: 1576.000000, diff_total: 1568.000000
** (com.github.stsdc.monitor:1544884): DEBUG: 13:27:50.150: CPU.vala:26: 1.005102, 101
** (com.github.stsdc.monitor:1544884): DEBUG: 13:27:50.150: CPU.vala:26: 1.005102, 101

Video: https://youtu.be/kwRwTUMl5mY

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

No branches or pull requests

2 participants