-
Notifications
You must be signed in to change notification settings - Fork 449
Adding OSX support #27
Comments
I have a Mac and I am willing to help:
|
@f1337 Thanks! I just added links to the issues for the CPU percents and process info which should help. Let me know if there's anything else you need. Also, I haven't determined why the temperatures widget doesn't work and I haven't opened an issue for it yet either. Temperature info is gathered here so checking the output or seeing if it just runs slow would be good. |
sorry, temperatures feature on Darwin has been removed due to mistakenly-included GPL code (see 518) |
for the temperatures widget: gotop is GPL, so i will try to reinstate the code that was removed from goposutil, within this project. |
re: cross-compiling, one of these solution may be helpful:
(this is mostly a note-to-self) |
re: process list performance, maybe i'm mis-reading the source, but it looks like syscall is already being used? shirou/gopsutil#513 (comment) in the meantime, i'm testing compiling against go 1.9 and 1.8, to see if that has any effect. UPDATE: Go 1.8 and 1.9 had no noticeable effect on performance on my mac. UPDATE 2: in theory, it is possible that cgo itself is to blame for the performance issues. messaging betw Go and C isn't free. still investigating. |
@f1337 xgo looks interesting. I can try building a binary using that and have you test it at some point. I also didn't know about the CGO_ENABLED env variable used at build time either, so I can try that too. Migrating away from using cgo in gopsutil would also be good, since they only use it for Darwin and it seems like a goal for them to not use it at all. Dunno how long/difficult that would be. |
xgo runs in a Docker container, so its "native" OS is linux. I'm testing locally right now, should have some results shortly. :) I'm not sure the CGO_ENABLED flag will actually work if re: gopsutil moving away from cgo, the issue appears to be that CPU times via the Mach kernel require C libs: shirou/gopsutil#66. The previous solution involved compiling a binary helper for Darwin installs, which is arguably worse. 🤷♂️ |
@cjbassi I am happy to test any binaries you build. 👍 re:
Note the difference in size between the generated binaries:
|
Wow, very awesome and building for me was a breeze. 👌 Here's the 64bit binary in a zip file for you to test again (didn't know if there's a better way to upload this): |
Yours worked for me! Still the 12s spin-up time, but no crashing! 🎉 I am working on a pull-request that adds a bash script for compiling via xgo to the goreleaser post-build-hook. I have tested it on my own fork, and it's working nicely (needs a wee bit of cleanup). Here is the release I just created, with a working Darwin build via xgo: https://github.com/f1337/gotop/releases/tag/1.2.15 |
re: temperatures => we are using an older version of gopsutil, which still has the GPL'd code. Our problem is that the temperature code in gotop is ignoring sensors that don't have "input" in the name, and MacOS sensors don't conform to that pattern:
The sensor keys for MacOS/Darwin can be seen here: shirou/gopsutil@c95755e?diff=unified#diff-519d82962db93621287a0d1ff038f5c6L67 Of course, now that gopsutil has dropped Apple's GPL'd code, we'll also need to re-introduce it to gotop, one way or another. |
re: startup performance, my debugging above demonstrated that during the ~12 seconds gotop takes to start on MacOS, the temp widget's update() method is called every second. We may be able to get some quick startup-performance gains by ensuring the widgets aren't calling update() until all are ready. I'll keep digging. |
The slow startup time is actually just a side effect of process info retrieval taking a really long time on Mac. Gotop isn't loaded until each widget is loaded and updated with info, which isn't a problem on Linux but takes a long time on Mac because it takes ~12 second to update process info. However, we're supposed to be updating process info every second too. As far as getting the info goes, the issue isn't actually with the Lines 77 to 81 in 8e750b8
I tried getting process info in parallel using goroutines to speed things up, but that just put CPU usage at 100%. So it's an issue of CPU usage and speed. Hope that makes sense XD edit: It would probably be good to play around and see which of the 3 Process methods are the culprit (I'm guessing its CPUPercent) |
I did some logging on my mac, and the results are interesting:
proc_startup.log Unrelated to performance, I also noticed some interesting discrepancies w/ Activity Monitor:
|
Very nice, thanks! Can I ask how you generated those logs? So the issues with CPUPercent and MemoryPercent make sense, since gopsutil is calling the |
To generate the logs, I mangled
|
Alright I think I've made a bit of progress on things. 😅 For the processes issue, I've actually switched from using gopsutil to calling For the temperatures issue, I've made a branch called 'temps' that needs to be tested on Darwin. I basically updated gopsutil through dep, added back the gpl code that was removed, and then made separate files for the temperature widget's update method for each platform. |
I'll test the latest on Darwin this weekend. Apologies for the delayed replies the past couple weeks, I've been too busy to do anything fun. |
🎉 It works! That is, no 12-or-more seconds delay on startup. I had to make one change on line #27 of
|
Great! I just fixed that one line in |
with one minor typo fix, temps work: #36 :) |
I merged everything and got some releases up some hopefully everything is working now! Could you try installing gotop using homebrew, making sure it works, and making sure the version number is 1.4.0? Install through Homebrew with:
|
Yay! Good to see. Ran into some issues with goreleaser and xgo but I'm glad that it's working. Just wanted to say thanks for the troubleshooting, testing, and PR's and that it's been fun getting this to work! XD Gonna add you to the Credits section of the readme cause I appreciate it. |
awesome, you're welcome, and thank you! |
Need to fix the following issues caused by gopsutil on OSX:
I don't have a Mac to test on so help is appreciated.
The text was updated successfully, but these errors were encountered: