limit CPU usage to transmission-daemon

Ask for help and report issues not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
jlazkano
Posts: 13
Joined: Sun Jul 12, 2009 9:05 pm

limit CPU usage to transmission-daemon

Post by jlazkano »

Hello forum, I am using transmission-daemon on a Linux server, I notice that when I start the service it takes lots of CPU usage checking the files.

Is possible to limit the CPU usage of this process?

Thanks and best regards.
liquidraver
Posts: 5
Joined: Tue Sep 20, 2011 2:19 pm

Re: limit CPU usage to transmission-daemon

Post by liquidraver »

hello!

I use nice to calibrate the CPU usage. it will not drop down the overall usage, but will give priority to other processes.

this is how I start the daemon:

nice -n 19 transmission -c "/usr/local/bin/transmission-daemon -g /etc/transmission-daemon/"

19 is the lowest possible priority 0 is the default and negative numbers are the highest
jlazkano
Posts: 13
Joined: Sun Jul 12, 2009 9:05 pm

Re: limit CPU usage to transmission-daemon

Post by jlazkano »

Thanks!

I want to make the same as you, I have PVR to watch and record tv and I want to min the transmission process impact. I use debian default init script:

Code: Select all

# cat /etc/init.d/transmission-daemon 
#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          transmission-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the transmission-daemon.
### END INIT INFO

NAME=transmission-daemon
DAEMON=/usr/bin/$NAME
USER=debian-transmission
# FIXME: no pidfile support; forks, so --make-pidfile doesn't work either
PIDFILE=/var/run/$NAME.pid
STOP_TIMEOUT=3

export PATH="${PATH:+$PATH:}/sbin"

[ -x $DAEMON ] || exit 0

[ -e /etc/default/$NAME ] && . /etc/default/$NAME

. /lib/lsb/init-functions

start_daemon () {
    if [ $ENABLE_DAEMON != 1 ]; then
        log_progress_msg "(disabled, see /etc/default/${NAME})"
    else    
        start-stop-daemon --start \
        --chuid $USER \
        --exec $DAEMON -- $OPTIONS
    fi
}

case "$1" in
    start)
        log_daemon_msg "Starting bittorrent daemon" "$NAME"
        start_daemon
        log_end_msg 0
        ;;
    stop)
        log_daemon_msg "Stopping bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON --retry $STOP_TIMEOUT \
            --oknodo
        log_end_msg 0
        ;;
    reload)
        log_daemon_msg "Reloading bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON \
            --oknodo --signal 1
        log_end_msg 0
        ;;
    restart|force-reload)
        log_daemon_msg "Restarting bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON --retry $STOP_TIMEOUT \
            --oknodo
        start_daemon
        log_end_msg 0
        ;;
    *)
        echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart}"
        exit 2
        ;;
esac

exit 0
Where would be the best place to add nice?

How can I check process nice value? Thanks for your reply.

Kind regards.
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: limit CPU usage to transmission-daemon

Post by blacke4dawn »

I would just change the start function a little:

Code: Select all

start_daemon () {
    if [ $ENABLE_DAEMON != 1 ]; then
        log_progress_msg "(disabled, see /etc/default/${NAME})"
    else    
        start-stop-daemon --start \
        --chuid $USER \
        --nicelevel 19 \
        --exec $DAEMON -- $OPTIONS
    fi
}
This seems to be the only code in there that starts it.
jlazkano
Posts: 13
Joined: Sun Jul 12, 2009 9:05 pm

Re: limit CPU usage to transmission-daemon

Post by jlazkano »

Thanks!!!

I add and it is working. How can I check the nice level of each process? It will be good to adjust some other processes.

Thanks and best regards.
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: limit CPU usage to transmission-daemon

Post by blacke4dawn »

Hmm, two easiest ways are:

Code: Select all

top

Code: Select all

ps -ao pid,comm,nice
top is a form of "live" resource viewer and will update every 2 secs, but look at the NI column.
ps is a full one-time listing, and probably better for your needs in this regard.

If you are going to change nicelevel on existing processes then use renice:

Code: Select all

renice <prio nr> <pid nr>
You can get the pid from the ps command above.
Post Reply