Themekit: macOS high CPU usage on `theme watch`

Created on 23 Feb 2017  路  20Comments  路  Source: Shopify/themekit

There is a high CPU usage when the theme watch command is left active for large periods of time. It makes my macbook fans run on high. The current solution is to exit it, and start the theme watch command again.

I know it only happens when the theme watch is active for a large period of time, but I thought I would mention it in case there is a process loop that is multiplying itself.

(I originally posted the issue here forgetting the app has moved to this repo)

Most helpful comment

Hey all, I managed to refactor out some things that were running in the watch event loop and got the cpu usage down to < 1%. I will keep testing it for the next little while and let you know how it goes.

All 20 comments

Hey thanks for letting me know. About how long would you say it has to run? An Hour or longer? Is it just CPU usage or have you checked your memory usage as well?

Hey Tim!

It's after an hour or so - hence why it isn't normally noticeable.

I have 'activity monitor' always running in my dock to watch out for high CPU usage, as it useful to spot when a program is spiralling out of control 馃槒

As far as I remember, it is just CPU usage. I am sure I would have mentioned about a memory leak, if so.

If you have a mac handy...

  • Open up Activity Monitor.
  • Go `View > Dock Icon > Show CPU Usage' (Not a requirement, it just useful to visually see what the cores are doing).
  • Run theme watch
  • Walk away for an hour or so to carry on with daily chores, and then come back to the mac.

It still happens if you walk away, do daily chores, or not - I have notice the issue even when actively working with themekit, over an hour or so.

:octocat:

Okay thanks I will look into it thanks!

Hey @ckhatton I cannot reproduce this. Do you have any other programs running at the same time?

I need a few other bits of information:

  • themekit version
  • macOS version
  • memory size
  • are you running an IDE or editor at the same time
  • are you running anything else like slack?

Cheers.

Okay sure.

  • themekit version 0.6.4
  • macOS version 10.12.3
  • memory size 16GB
  • are you running an IDE or editor at the same time yes, Atom
  • are you running anything else like slack? yes, Slack

I am running theme watch now to see if I can still reproduce the issue.

馃悷

This is after an hour...

Screenshot 01

This is after 5 hours. The 'theme' process recorded with 11.2 MB of RAM allocated...

Screenshot 02

To be fair, it hasn't been as bad as it has been in the past, but there is an issue still present. It might because I have been out for those 5 hours, and not actively using the themekit. In fact, the macbook might have been asleep. :suspect:

Thanks I will look into it and see what can be done about it. There shouldn't be much running when it has nothing to process but maybe I am missing some sort of edge case.

This is interesting, maybe you should try upgrading but I have been running watch all day and it stays hovering around 14%. You should try updating but also I will be releasing a new version soon with a new version of go that may help it.

image

When profiling it, there is nothing that increases more than it should.

It seems like if it is anything it will be something in Go because out of all of the top processes being used, anything from themekit is not even in the top ten.

screen shot 2017-02-24 at 4 20 36 pm

How did you output those stats?

Here is another screenshot after updating themekit to the latest version (v0.6.9). The CPU time is similar to yours, though it's only run about an hour as the macbook went to sleep.

Screenshot 03

Those stats are done through Go's profiling libraries. I added them permanently in this PR for easy profiling in the future.

Also facing this issue on mac 10.10.4 with go1.7.4 darwin/amd64. Will check if upgrading to Go 1.8 helps.

@raulk are you compiling themekit yourself? What is themekit's peak usage?

+1. mac 10.12.3 themekit 0.6.9

Started at 0.6%

screen shot 2017-03-07 at 21 45 26

Left it on overnight, roughly 12 hours later of inactivity it's at 24.8%.

screen shot 2017-03-08 at 10 30 44

Doesn't seem as bad as @ckhatton but the issue is still evidently present.

@tanema Nope. I'm not compiling themekit myself. So upgrading Golang in my system has no relevance.

The issue is pretty severe on my end. It actually prevented my Mac from going to sleep last evening. When I came to it this morning, the fans were at full speed and the CPU was at ~90%.

@raulk okay thanks for the update. That is really not good.

That's what I used to have, but I never noticed the sleep issue as the fans were already audible enough to make me investigate what was going on. I imagine something has updated on my system since, for it not be such a big issue now 馃

Hey all, I managed to refactor out some things that were running in the watch event loop and got the cpu usage down to < 1%. I will keep testing it for the next little while and let you know how it goes.

Good work! I will monitor it next time I run theme watch 馃

I just released v0.6.10, please update and try it out!

Was this page helpful?
0 / 5 - 0 ratings