Comments (10)
On a suggestion over in shirou/gopsutil#842 by @AtakanColak, I tried go-sysinfo. Despite eliminating the forking & parsing of output, and string manipulation and parsing to produce numbers, it's still twice as slow as forking ps
. It's significantly faster than gopsutil, but still more CPU intensive than forking. I feel like I have to keep saying that, because it's so difficult to believe. In any case, it stays how it is on Linux, and I think the way forward is one of the suggestions above: detect when gotop is running in busybox and use go-sysinfo there.
from gotop.
Gory details are in shirou/gopsutil#842, but the summary is: a benchmark shows that elastic/go-sysinfo is marginally faster than the current forking/parsing code. It doesn't explain why top
showed that version as having higher CPU use, but I'm willing to give it a shot if it means supporting more environments.
from gotop.
Another hiccup: go-sysinfo
fails to get information about many processes when run as a user because it doesn't have access to all processes in /proc
. This may be insurmountable.
from gotop.
Busbox support sounds good to me. It would probably require us to do some check on the environment on start and adjust the ps
flags. I'm curious what the adjustments would be. Is that actually the entirety of the man page? 😂 If not, could you copy the contents into a gist or link it?
So can you test this command: ps -o pid,comm,pcpu,pmem,args
? Also, there's been some issues with the ps
columns being cropped, so if that happens when running that, then you can try doing ps -o pid,comm=superlongheaderasdfasdfasdfsdaf
etc.
from gotop.
Unfortunately it is the complete manpage :(
[~] # ps -h
ps: invalid option -- 'h'
BusyBox v1.24.1 (2018-12-28 02:26:16 CST) multi-call binary.
Usage: ps [-o COL1,COL2=HEADER] [-T]
Show list of processes
-o COL1,COL2=HEADER Select columns for display
-T Show threads
QNAP Options:
--columns N
[~] #
With yours commands i get :
ps -o pid,comm,pcpu,pmem,args
ps: bad -o argument 'pcpu', supported arguments: user,group,comm,args,pid,ppid,pgid,etime,nice,rgroup,ruser,time,tty,vsz,stat,rss
I removed pcpu and pmem (because it's not recognized) and i get things like this :
[~] # ps -o pid,comm,args
PID COMMAND Command
1 init init
2 kthreadd [kthreadd]
3 ksoftirqd/0 [ksoftirqd/0]
5 kworker/0:0H [kworker/0:0H]
7 rcu_sched [rcu_sched]
...
I don't see any problems with cropping (i have some very long "Command" entries).
from gotop.
So it looks like ps
on busybox doesn't support per process cpu usage or memory reporting. So we should check if we're on busybox and then our only option is to remove the unsupported flags and only show PID and command.
from gotop.
The only way i find to get cpu or memory reporting is to use top.
If you need other tests, i'm available ;)
from gotop.
Some new ideas about different ways to fix this:
- detect when a system uses busybox, then use cli args appropriate for
ps
on a busybox system, but we won't be able to get per-process cpu or memory usage - require users to download and install
procps
on their system as a workaround - directly gather process information ourselves by traversing
/proc
, or use the implementation provided by gopsutil
3 sounds best to me. We were originally using gopsutil to gather process information but I forget why we switched of it. And it should be easy to test gopsutil's implementation (I've just been busy).
from gotop.
Note to self:
docker run -it --name gotopbb --rm busybox
CGO_ENABLED=0 go build -a -v -o gotop ./cmd/gotop
docker cp ./gotop gotopbb:/bin/
from gotop.
- directly gather process information ourselves by traversing /proc, or use the implementation provided by gopsutil
3 sounds best to me. We were originally using gopsutil to gather process information but I forget why we switched of it. And it should be easy to test gopsutil's implementation (I've just been busy).
(Emphasis mine). Well, I found out why. CPU use quadruples under the gopsutil
library vs repeatedly forking ps
. Frankly, this surprises the heck out of me. However, changing to gopsutil
does (a) remove the need for all of the OS-specific procs sources, and (b) enable procs to work properly on BusyBox.
I've filed shirou/gopsutil#842, and will leave this ticket open until a clear path forward is defined.
@Mikiya83 FYI
from gotop.
Related Issues (20)
- Battery information is not displayed. HOT 1
- Statusbar set to true in the configuration file but is not displayed
- $TERM rendering bug HOT 6
- 4.2.0 is broken HOT 1
- Temperature not showing for M2 Air HOT 5
- build from source failed on macOS HOT 1
- Only show one widget or create custom layout
- RX e TX Network for all time HOT 2
- Disk report problem on each run HOT 3
- gotop only opens keybinding overview HOT 1
- Please bump the golang.org/x/sys dependency
- 404/301 errors when trying to emerge gotop from gentoo guru repo
- Build fails because go.mod requests an outdated Go version HOT 1
- Detected as Trojan
- --nvidia and --export cannot be used at the same time
- AMD GPU support HOT 1
- gotop doesn't work in tmux HOT 3
- Issue with Absolute Path for Layout File in Termux
- Build error on Mac
- Cannot compile to AIX ppc64
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotop.