# rtorrent 0.8.9 high cpu



## Nawunk (Jul 25, 2011)

I seem to be having an issue with rtorrent 0.8.9 from ports. Each time I hit the web interface (in my case rutorrent), the CPU usage shoots up for around 30secs. Going by that I'm guessing it's something to do with XMLRPC.

I'm using:
FreeBSD 8.2-RELEASE on amd64
rtorrent 0.8.9/libtorrent 0.12.9
rutorrent from SVN

Just wondering if anyone else had the same issue or managed to narrow the cause down?


----------



## DutchDaemon (Jul 25, 2011)

Try rtGUI as an alternative, if only to pinpoint the culprit.


----------



## Nawunk (Jul 27, 2011)

I gave rtgui a go and had the same problem. Just remembered that xmlrpc-c came with a cli tool as well so I used that to pull out some generic data and the CPU usage shot up again. I'm not sure what it is with 0.8.9 that's causing it for me, other versions didn't have the issue (0.8.6 and 0.8.7).


----------



## SirDice (Jul 27, 2011)

I seem to have a similar issue but with net-p2p/transmission. As far as I've been able to find it looks like it's related to firefox. When the transmission web interface loads 7 out of 10 times CPU shoots up to 100%. But it's not transmission because that's running on another box. I've got the feeling it's some javascript that gets loaded which freaks out firefox. Had the same issue with FF4 but never with 3.6.


----------



## DutchDaemon (Jul 28, 2011)

A new version of xmlrpc just hit the ports tree earlier. See if that helps. I don't have a problem with it (rtGui/Chrome).


----------



## Nawunk (Jul 28, 2011)

Thanks but I've already tried the new xmlrpc.

If you're not having any issues it may only be under certain circumstances or just my install. When I get the time I'll build up a few VMs to try and see if I can replicate it


----------



## OH (Jul 28, 2011)

I can confirm this problem. I've tried different versions of xmlrpc-c-devel and rtorrent and I can safely say it happens not in rtorrent 0.8.6 and does happen in rtorrent 0.8.7, 0.8.8 and 0.8.9.
I suspect it might be caused by the multithreading for xmlrpc-calls introduced in version 0.8.7.

When I truss the rtorrent process while trying to access rtorrent 0.8.9 through xmlrpc I get this:

```
gettimeofday({1311848582.590548 },0x0)		 = 0 (0x0)
kevent(4,{0x7,EVFILT_READ,EV_ADD,0,0x0,0x0},1,{0x7,EVFILT_READ,0x0,0,0x6d1,0x0},16384,{0.548000000 }) = 1 (0x1)
recvfrom(7,"456:CONTENT_LENGTH\0001284\0SCGI"...,2047,0x0,NULL,0x0) = 1745 (0x6d1)
thr_kill(0x18889,0x1e,0x801dd7e40,0x18731,0x1,0x802c30000) ERR#4 'Interrupted system call'
SIGNAL 30 (SIGUSR1)
sigreturn(0x7fffffffe190,0x10001,0x4153a0,0x0,0x7fffffffe640,0x4d1ad0) ERR#4 'Interrupted system call'
thr_kill(0x18889,0x1e,0x801dd7e40,0x18731,0x1,0x0) = 0 (0x0)
SIGNAL 30 (SIGUSR1)
thr_kill(0x18889,0x1e,0x801dd7e40,0x18731,0x1,0x0) = 0 (0x0)
sigreturn(0x7fffffffe190,0x10001,0x4153a0,0x0,0x7fffffffe640,0x4d1ad0) ERR#4 'Interrupted system call'
SIGNAL 30 (SIGUSR1)
thr_kill(0x18889,0x1e,0x801dd7e40,0x18731,0x1,0x0) = 0 (0x0)
```
This continues on and on. the log grew to 40 megabytes in seconds, the call never completed, rtorrent hung, truss hung. The call would complete if truss is not attached, it just takes a while.

Under 0.8.6 all is well:

```
recvfrom(6,"454:CONTENT_LENGTH\000133\0SCGI"...,2047,0x0,NULL,0x0) = 592 (0x250)
sendto(6,"Status: 200 OK\r\nContent-Type: "...,208,0x0,NULL,0x0) = 208 (0xd0)
close(6)					 = 0 (0x0)
(...)
recvfrom(6,"454:CONTENT_LENGTH\000130\0SCGI"...,2047,0x0,NULL,0x0) = 589 (0x24d)
sendto(6,"Status: 200 OK\r\nContent-Type: "...,423,0x0,NULL,0x0) = 423 (0x1a7)
close(6)					 = 0 (0x0)
(...)
recvfrom(6,"454:CONTENT_LENGTH\000137\0SCGI"...,2047,0x0,NULL,0x0) = 596 (0x254)
sendto(6,"Status: 200 OK\r\nContent-Type: "...,215,0x0,NULL,0x0) = 215 (0xd7)
close(6)					 = 0 (0x0)
(...)
recvfrom(6,"454:CONTENT_LENGTH\000138\0SCGI"...,2047,0x0,NULL,0x0) = 597 (0x255)
sendto(6,"Status: 200 OK\r\nContent-Type: "...,216,0x0,NULL,0x0) = 216 (0xd8)
close(6)					 = 0 (0x0)
```

I use a self-written webGUI, HTML only.


----------



## flow (Aug 21, 2011)

I had the same problem you are describing. Whenever I tried to browse to rutorrent it wouldn't finish loading and the CPU usage of rtorrent would more or less max out.

But I managed to find the solution to this, as it seems to be a known bug that recently has been fixed in rtorrent. http://libtorrent.rakshasa.no/ticket/2661

Modifying the source and recompiling helped for me.

FreeBSD 9.0 Beta 1
rtorrent 0.8.9
libtorrent 0.12.9
rutorrent 3.3


----------



## OH (Aug 21, 2011)

That works perfectly (8.2). Depending on how long it takes for the next release of rtorrent to get out, this should be fixed in the port.


----------



## alexk (Sep 1, 2011)

The patch on src/thread_base.cc from r1263 work for me, thanks everyone!


----------



## Nawunk (Sep 7, 2011)

Thanks for the info Flow, I'll give that a go.


----------

