Dropbox is taking too much CPU time. How can I fix it?
I recently noticed that Dropbox is taking about 50-90% of my CPU for more than just a few seconds sometimes - mostly when downloading/syncing many or large files.
Still, I guess that even when syncing a lot of data, there's no reason to use that much CPU (perhaps network or disk..)
Any ideas or suggestions? How can I make Dropbox use less CPU?
(running on Ubuntu 12.04 on Lenovo X220 with SSD Drive)
Good shout with using cpulimit.
I found this could be simplified (when logged as root) to
cpulimit -e dropbox -l 10
where -l specifies percentage of CPU. Note this is for total CPU over all cores, so a dual core would have a limit of 200
Output:
cpulimit -e dropbox -l 10
Process 2641 detected
Dropbox computes a hash of all files that it's going to sync, it uses it both to determine if they changed and to avoid uploading content that is already in their cloud (another customer has the same file).
Calculating hashes takes CPU power. It's usually noticeable at login.
You can limit the cpu usage of any application this way:
#nPidDropbox=`ps -A -o pid,comm |egrep " dropbox$" |sed -r "s'^ *([[:digit:]]*) .*'\1'"`
nPidDropbox=`pgrep dropbox`
renice -n 19 `ps -L -p $nPidDropbox -o lwp |tr "\n" " "`
cpulimit -p "$nPidDropbox" -l 10
The first line of code is just a pid guesser.
The 2nd line is to help cpulimiter
work better while not requiring sudo
.
Perhaps there is more to it than the problem of hashing.
One thing that I find strange is that with lsof | grep dropbox
I do not see many open files under ~/Dropbox for the dropbox process.
What I did was to aptitude purge all packages related to dropbox, rm -r the 3 ~/.dropbo* folders (but not the ~/Dropbox folder), and then enable partner repositories and aptitude install nautilus-dropbox
. Whether this procedure is problematic I do not know.
After a while (an hour?) with the new install and with dropbox CPU load I no longer see the load, so apparently the problem is solved. Perhaps the purging has helped or I just had a very large batch of files that needed updating.