3hhh / qubes-conky

a conky configuration for Qubes OS
GNU General Public License v3.0
6 stars 0 forks source link

Question regarding calculation in the section "Qubes VM Performance" #1

Closed one7two99 closed 1 year ago

one7two99 commented 1 year ago

Hello 3hhh, appreciate your work and took your work as foundation for my own conky setup.

I found out that the calculation done in https://github.com/3hhh/qubes-conky/blob/master/conky_qubesSettings.conf will always show a much higher CPU-utilization for Domain-0 that it is. The root cause seems to be within this code:

[...]
conky.text = [[
${color grey}Qubes VM performance:
${execp xentop -f -b -i2 -d0 | tail -n+2 | sed -r -n '/NAME/,$ p' |  sed -r -n 's/^\s*([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+.*$/\1${goto 140}\4${goto 220}\9${goto 300}\6${goto 400}\8/p'}
[...] 

More precise:

xentop -f -b -i2 -d0

the last option (-d0 = --delay 0) seems to produce a CPU peak durinf the run of this command, so that CPU utilization is much higher.

Domain-0 CPU utilization with delay > 0

... will be shown as 4,8% (see last line)

user@dom0 ~]$  xentop --full-name --batch --iterations 2 --delay 1
         NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR  VBD_RSECT  VBD_WSECT SSID
     Domain-0 -----r      12267    0.0    4177920   12.6    4195328      12.6     2    0        0        0    0        0        0        0          0          0    0
[...]
         NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR  VBD_RSECT  VBD_WSECT SSID
     Domain-0 -----r      12267    4.8    4177920   12.6    4195328      12.6     2    0        0        0    0        0        0        0          0          0    0
[...]

CPU utilization with delay = 0

... will be shown as 133% (!) - see last line.

[user@dom0 ~]$  xentop --full-name --batch --iterations 2 --delay 0
         NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR  VBD_RSECT  VBD_WSECT SSID
     Domain-0 -----r      12268    0.0    4177920   12.6    4195328      12.6     2    0        0        0    0        0        0        0          0          0    0
[...]
         NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR  VBD_RSECT  VBD_WSECT SSID
     Domain-0 -----r      12268  133.0    4177920   12.6    4195328      12.6     2    0        0        0    0        0        0        0          0          0    0

Can you explain, why you have used delay 0 and iterations 2 in this command?

3hhh commented 1 year ago

Can you explain, why you have used delay 0 and iterations 2 in this command?

Good question...

I guess because I didn't want conky to wait for 1s (your case) or 3s (default) on the execution of the command - --delay appears to be the time between iterations.

I just double checked and noticed that --iterations 1 will always show zero CPU usage on my host and --delay 1 sometimes also produces high CPU usage; the default as well. IMHO the dom0 CPU usage displayed by xentop isn't much reliable or possibly shows 100% for a single CPU (i.e. 4 cores = max 400%), idk.

If you find a more precise way to use xentop, please let me know.