Since upgrading to macOS Sierra (10.12.1) I’ve been having problems with the VTDecoderXPCService process spinning out of control. Closing the Messages app will fix this, but inevitably starting Messages at a later time will cause the problem to resurface. I didn’t really want to fire up IDA Pro and dig into why VTDecoderXPCService was doing this, so I instead thought I’d use cputhrottle to limit how much CPU it is allowed to consume.
You can download and compile cputhrottle yourself, or install it with brew:
1 |
brew install cputhrottle |
Unfortunately VTDecoderXPCService is owned by launchd, which means cputhrottle isn’t allowed to throttle it. This is due to an error when calling task_for_pid (error 5, KERN_FAILURE). So you’ll have to disable the System Integrity Protection (SIP), sadly.
Simply reboot your machine and hold Command-R to enter recovery mode. Then start terminal and run this command:
1 |
csrutil disable; reboot |
Now cputhrottle can limit VTDecoderXPCService!
I created a ruby script called limit_decoder.rb which will throttle the service for you. You could simply run this in Terminal and call it a day, or you could configure it to start with your machine. Steps to achieve this:
- Download limit_decoder.rb and save it somewhere.
- Make it executable:
1chmod +x limit_decoder.rb
- Create a plist within /Library/LaunchDaemons/, mine is called com.geesu.limitdecoder.plist
- Insert the following into the above plist (change the path!):
123456789101112<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>Label</key><string>com.user.loginscript</string><key>Program</key><string>/path/to/limit_decoder.rb</string><key>RunAtLoad</key><true/></dict></plist> - Now launch the command with the following:
1sudo launchctl load -w com.geesu.limitdecoder.plist
and you can unload it with:
1sudo launchctl unload -w com.geesu.limitdecoder.plist
If you run into any problems you can view the /var/log/system.log for any errors.
Enjoy!