clbr / radeontop

GNU General Public License v3.0
785 stars 69 forks source link

Option to show only gpu usage percent #167

Open Lowrida opened 2 weeks ago

Lowrida commented 2 weeks ago

A friend of mine has an older system and a dump to terminal takes a long time. Too long for a nice update in conky. He only wants the gpu usage. Is it possible to make an option for that?

He can't cat the gpu_usage_percent file, because Option not permitted

clbr commented 2 weeks ago

I'm afraid it won't be any faster if the other values were ignored. The GPU usage queried is an "on/off" value, and to get a percentage it needs to be sampled over a certain time. That is, if you changed it to return immediately after one sample, you'd only get 0% or 100%, not very useful.

I'm not sure what file you're referring to? But for conky, you'd probably want a two-step solution so direct reads are fast. Run radeontop in the background, updating one file, and in conky's config you'd read that file.

Lowrida commented 2 weeks ago

Thank you for your reply. I revered to /sys/class/drm/card0/device/gpu_busy_percent Where does radeontop get it's gpu usage from? How does it calculate it?

clbr commented 2 weeks ago

It uses the status register. "At this point in time, which units were on". By default it samples 120 times per second, and outputs once per second. So with the defaults, the calculation is the sum of 120 status reads divided by 120 (and multiplied by 100 so it becomes %).

Lowrida commented 2 weeks ago

Ah ok, now i get why it takes at least a second to perform a dump. But even when i set tick to 10 it takes the same time to perform a dump..

clbr commented 2 weeks ago

Tick affects the accuracy, how many times per second to sample. There is no option to change the interval currently. Using too short an interval would cause very jittery (wrong) results.

Lowrida commented 2 weeks ago

Ok, thanks for the explanation! I guess running it in the background dumping to a file and then cat the file would be quicker then running it every time conky updates.

Lowrida commented 2 weeks ago

Problem is, the file grows in size very quickly! Is there an option to not append, but renew the file so only one line is in it?

clbr commented 2 weeks ago

Not in radeontop, but I'm pretty sure other conky users have made scripts for that. I don't have links at hand, though, sorry.

radeontop -d - | keep-last-line.sh /tmp/gpu
Lowrida commented 2 weeks ago
radeontop -d - | keep-last-line.sh /tmp/gpu

That pipe doesn't work. That script does not get anything on $@ or $1 .

clbr commented 2 weeks ago

The file name was for it to output, the input comes through the pipe? If you're not familiar with scripting, you could ask for help at ubuntu forums, etc.

Lowrida commented 2 weeks ago

Yeah, no problem in scripting here... but the pipe does not work!