GuillaumeGomez / process-viewer

A process viewer GUI in rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Too high CPU

Anachron opened this issue · comments

This tool generates about 10-25% of a single core, using Linux Mint 17.1 Rebecca with Cinnamon 2.6 (8GB ram, 8 cores 3.1ghz, 2GB intel HD 4000, 500GB SSD).

I have an issue here. Comparing to htop, my values are ~3% too high. I'm still trying to fix the computation (if you have any clue, it's very welcome !).

Can't seem to find any issues so far with the source, will keep investigating.

I launched two processes (each one use ~20% of a processor) and the values were even more wrong. The problem gets deeper.

I've done some digging and was asking, how did you come to this calculation?
https://github.com/GuillaumeGomez/sysinfo/blob/master/src/process.rs#L77

I'm not sure why but for me this looks not correctly...

I couldn't find the old computation I used back in high school so I tried some, based on my comprehension of man proc.

So I'm guessing this is how you did it?

http://stackoverflow.com/a/1424556

https://github.com/GuillaumeGomez/process-viewer/blob/master/src/process_viewer.rs#L232
https://github.com/GuillaumeGomez/sysinfo/blob/master/src/process.rs#L77

So you actually pass a smaller float and recalculate it in %. (*100)

It should be correctly, but maybe some values are getting messed up when reading them from file-system? Did you do some debugging to check whether it's always the correct process-data being returned to calculate? (From the FS)

I did, but certainly not enough. I spent my w-e trying to create TreeSortable trait in gtk in order to allow sorting/filtering. Unfortunately, I discovered an ICE so we'll have to wait for this haha.

I'll try to see this evening if there isn't bad values in computation.

I'm guessing you are talking about this ICE:
rust-lang/rust#26076

When is the code refactoring planned?
As I've experienced, it's better to do it in the beginning when the LOC is still small.

As soon as @gkoz has finished it.

This issue is now solved. I close this issue.