Tuesday, August 28, 2012

Mac OS X Lion: kernel_task with High CPU

My Mac has occasionally been going nuts and the fans start spinning up like crazy.  Tonight I sat down and took another stab at finding the culprit.

First I took at look with Activity Monitor but nothing obvious in My Processes.  So I switched to All Processes to see what root processes were doing.  Bingo, a nondescript Process Name called kernel_task was eating up just over 100% (110% before turning off some apps).

I read this article (Kernel_task process taking up an inordinate amount of CPU) at MacFixIt, which indicated to start cleaning stuff up (ya, I knew that, housekeeping). 

First I uninstalled some stuff that sounded good but which I just never use:
  • ShoveBox
  • Eye-Fi
Ok, CPU usage on kernel_task now down to about 104%.

Then I brought up the System Preferences -> Sharing panel.  In here I had Bluetooth sharing on for a previous project but I am not currently using it.  So I turned that off.

Bingo!  Kernel_task is down to about a peak of 4% CPU usage now in a steady state (ie. when I am not opening new processes).

The basic gist is that kernel_task is a catchall for a multitude of system processes and hence it can take some rooting around playing with settings to get it to decrease.  Good luck.

Friday, August 24, 2012

Git + Code Collaborator: Post Checkin Code Review

Sometimes you submit your code before you setup a review with code collaborator.  Here are a couple ways to create a code review with code collaborator for git checkins.  I will cover the standard cases, before you stage the code, once the code has been staged for commit, and after you have submitted the code.

With Unstaged Changes

This one is easy, nothing special needed.
git status 
# On branch master 
# Changes not staged for commit: 
#   (use "git add ..." to update what will be committed) 
#   (use "git checkout -- ..." to discard changes in working directory) 
# modified:   changedFile.m 
Now run the command to add a diff of the modified files:
ccollab addgitdiffs new

With Staged Changes

This is not very tricky, but you do need to give the git diff option for staged files, --cached.

git status 
# On branch master 
# Changes to be committed: 
#   (use "git reset HEAD ..." to unstage) 
# modified:   changedFile.m
 Now run the command to add a diff of the cached/staged files:
ccollab addgitdiffs new --cached

With Committed Changes

This one is more tricky.  You have committed the files.  Let's use reflag to see the commits.  Then take the SHA1 hash of the commit you want to diff and the previous commit do a diff between commits.

git status 
# On branch master 
nothing to commit (working directory clean)

As you see, git status will not show any changes since you committer your work.

git reflog
aa90bc4 HEAD@{0}: commit: Changes I forgot to code review.
bb37e6c HEAD@{1}: commit: Some other changes

Now use the SHA1 hash of each commit to make your diff:

ccollab addgitdiffs new bb37e6c aa90bc4
Now you should have a code review with the difference between your changes and the previous commit.

Hope that helps