-
-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rTorrent reading 4x more data than sending #443
Comments
I've tried playing with the preload features to see if that causes it, I've tried disabling preloading and that doesn't help, nor does enabling it or making the memory cache larger. rTorrent doesn't seem to utilize the piece cache anyways even though i have it set to like 16G and have 300 torrents all seeding with active peers. |
I see you don't have throttling enabled. Can you enable throttling for both upload and download, and see if you can replicate it with throttling enabled. Your throttle should be 80% of your total maximum speed from your ISP. So if your upload speed is 20MB/s then set the upload throttle to around 17MB/s, and if your download speed is 100MB/s then set the download throttle to 80MB/s. If you are able to replicate it with throttling enabled, then please set the download throttle to something very low and see if the issue still occurs (uploads drop down to 1/4 of your throttled download speed) |
I did try this with throttling too. It seems to happen with lots of uploading slots and lots of torrents. I think what's happening is a slow client requests a piece, rTorrent loads the entire piece into memory, and attempts to send it but in smaller blocks. In the meantime many many torrents and clients are doing this causing an internal cache thrashing. So a piece is having to be reloaded every time a peer requests the next block because the piece gets kicked out of the cache due to other pieces being loaded. So instead of reading the entire piece from disk, how about just the block the peer requests? I know this is less efficient for most setups but an option to change the behavior on how data gets loaded from disk would be nice. |
Hmm.. Preload options might help here.
Sadly the documentation is lacking and I'm not an expert at reading this code, so I can't tell if that's 5192 bytes or a factor of time or what have you. Looks like valid values for type are 0 and 1, but no idea what either of those means. Try lowering the min_size in your rtorrent config and see if that helps any. |
I've also tried with and without preload, doesn't make a difference. |
You confirmed it happens even with just one active torrent and all others stopped? If you could, please test with just one active torrent, and the rest stopped, assuming you haven't already. ;-) If it doesn't happen there, then that will probably confirm the theory about slow clients, because you're then only dealing with a small subset of the number of peers you normally are interacting with. |
Here's the result of downloading a SINGLE torrent. With 0 upload speed. It's reading an insane amount of data for only downloading a torrent at 2MB/s. I mean what's the point of the freaking disk process? I'm using the 0.9.6 published build. TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND [Throttle 200/2048 KB] [Rate 2.3/2071.4 KB] [Port: 12345] |
Using a completely stock rtorrent and stock debian install (no .rtorrent.rc file)... downloading a SINGLE torrent with ZERO UPLOAD. TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND [Throttle off/off KB] [Rate 3.5/3091.0 KB] [Port: 6944] This is a huge performance impact for rTorrent. This renders it unusable for me and is likely impacting the entire userbase and they don't even know it. |
I can see it reading that much with hashing enabled but you have it off. Can you try to reproduce this with deluge? It uses libtorrent also, and will help to narrow down whether its a bug in libtorrent or rtorrent itself. |
Deluge uses a different libtorrent actually - libtorrent-rasterbar. I tried builds all the way back to 0.9.0 and they all are affected. I haven't tried prior versions since they won't compile under newer versions of the C/C++ compilers. Deluge does not have this same problem. It also performs significantly less write op/s too. I get maybe an average of 30 IOops every few seconds when the write cache is being flushed. When I was using rTorrentI was seeing a constant 300-400 IOops/s with rTorrent. TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND |
What OS is this exactly? Is it run on a physical device or in virtual environment?
As you can see, I don't have that insane fluctuation like you do.
I don't have Edit: I have to mention that I'm using modded |
I've just tried it, just in case (with the above linked config): downloading only 1 with zero upload.
This part seems to be good on my system. |
I made one more test:
It's about 2.5x . Can you try the similar test with deluge if it has any buffering option? I'm just curious. |
And the last test, testing buffer sizes, setting them during runtime:
It's about 4x . So, it seems that bigger buffer sizes can help a bit with this but not really.
I tend to think that you're right :) Now, all we need is somebody who can fix this. :) |
Why does it read ANYTHING during download? Unless you download more chunks in parallel than the system can cache all downloads should stay in memory until they are no longer needed. Only when doing the final hash check when the download is finished I would expect reads, unless the downloaded file is still in cache (likely for a single download test smaller than the ram).. So on that single download without upload what was the chunk size and how many chunks where downloaded in parallel? How much memory was there? |
The system had 8G of RAM which was way more than the size of the torrent. Also the torrent, I don't remember the chunk size, there were a few dozen seeds the box was connected to. rTorrent was allowed to use 1G of memory for cache. There's no reason it should be reading anyways during downloading. I'm wondering if rTorrent is trying to be so aggressive with it's caching that it's actually cache thrashing. Deluge does not have any of the same problems. Debian 8 system, virtualized, all measurements were taken inside the VM. |
How does rtorrent caching work at all? If it's just mmap()ing the file and then uses that as buffer to recv() then every page will be read in before being overwritten with the download. That would explain as much read as download at least. I hope this isn't the case. |
@mrvn As I mentioned before:
Can you also try it out? |
I have not benchmarked it but I have seen a lot more reads than my upload limit would suggest since basically forever. |
Maybe this issue is related in this way: #409 |
Reproduced downloading only 1 torrent with everything else stopped, on RaspberryPi 2 / 3 (running fresh install Raspbian/Debian Jessie). Tried all above config settings with no change. For reference, this is my up/down limit setting: When downloading to local disk on RPi, no issue. Hit limit set in .rtorrent.rc config. When downloading to NFS share, the issue happens. (Also tested with CIFS (samba) and still same issue). Tons of excessive reads when downloading 1 file! FYI, when copying file from local disk to NFS share, file transfer is fast. So not an issue with NFS share. (Hitting max of RPi ethernet). Note: ifstat is in bit per sec. iotop is in bytes per sec. $ ifstat -b -t -i eth0 1 |
Thanks for the detailed report. |
Upload limit 200KB. 1 torrent. NFS disk: TIME TID PRIO USER DISK READ DISK WRITE SWAPIN IO COMMAND Local disk: 09:20:25 11070 be/4 rtorrent 352.54 K/s 0.00 B/s 0.00 % 0.63 % rtorrent Note: both iotop and ifstat in bytes |
Thanks, that's indeed confirms this seeding bug with a local disk as well. |
Can this be related? rakshasa/libtorrent#83 |
Has anybody tried out this with |
I made test about the seeding issue again with local disk using 0.9.6: Note:
I. if
It's 4.6x more then it's needed. II. if
It's 7.4x more then it's needed. How can we debug this? |
I checked, it suffers from the same issue.
It doesn't, as it turned out: I checked the same instance at a different time and I got better results:
What interesting is the output of
As we can see, writing incoming data is buffered but not reading. Somebody has to take a look at this issue who is smarter than me. :) @rakshasa ? :) |
It sounds/looks like rTorrent is reading larger chunks than needed for each piece request from each seed slot. That would suggest the problem is actually in libtorrent. |
Just want to chime in here, I was looking into this myself I disabled the preloading feature, and it barely had an impact, but I then noticed data was been read in 32k chunks by the daemon, but of course the default read_ahead in the scheduler is 128k, as soon as I dropped that down to 32k on the data drives I now have no read amplification. I hope this helps. |
@chrcoluk can you please explain what needs to be changed, what scheduler do you mean? |
+1 |
On the OS kernel scheduler. check the value here /sys/block/sdb/queue/read_ahead_kb substitute sdb for the drive label on your system. |
Has anybody checked this? Does it work? Thanks |
Yep, tested and not worked for me. Same read-amplification, crazy load average and a ton of I/O Wait |
Same here. Or, the load average isn't bad, but reading from the disk being uploaded from is ruined for other programs. |
It could be my way of measuring is bad, I measured the amplification via proxmox (as my machine is a VM), and I had observed after decreasing the i/o read level, on the host machine dropped to about a 1.1 multiplier instead of around 4.6. Or it also could be you guys have different causes, I will try and do more monitoring and testing and get back after. |
My DL drive is unusable while rtorrent is uploading faster than 1MB/s. |
I can confirm @chrcoluk's finding's that lowering the readahead to match rtorrent's chunk size normalizes disk read. Tho i am using a network storage (over SMB3) instead of a local disk on a 10GBit link as the backend so change I did notice this after limiting the bandwidth on the rtorrent attached switch port which rendered the rtorrent server sluggish and unresponsive after running into the burst limit will uploading. Why ever this only affects uploads i have no idea. Metrics were taken directly from the storage NIC so the measurement is fairly accurate. |
@runaroundhome |
@sedago, nope, still got the issue. I switched over to qbittorrent, but it is much less aggressive at seeding/downloading compared to rtorrent. So I'm now running both about 20/80, with a total of ~600 torrents (20 being rtorrent). It seems to work kinda ok. I feel like we are missing something, because allot of the big seedboxs around are still offering rtorrent, and they'll have 100s if not 1000s of torrents running at the same time, can't say they're just chucking SSDs at the issue. |
@runaroundhome |
Hello! |
10Gbe up-link, i7-8700, XPEnology DSM 6.2.3, Btrfs RAID5 8x Ent. 6tb HDD 7200rpm with RAID0 3x1Tb SSD read cache, various popular docker containers with rtorrent+rutorrent gui. Maximum download and upload speed that I saw - 35-45Mb/s. PS: change read_ahead_kb didn't help me. |
The documentation send me here as it says:
I read through this issue.. but don't really see the solution. My goal: I have 32GB RAM, only 8-9GB is used in total, sometimes 12GB, excluding torrent client. WIth Transmission, setting The documentation provides a few clues by explaining settings, but I don't see a clear path to get rTorrent to use that much RAM before writing to disk. Hope someone can be helpful here as I don't like Transmission and would like to switch. I am a bit afraid to change My internet speed is 500/500 but I am limiting my torrent client to 160/84 megabit (20/12MB). |
@zilexa If you are under linux, you can play with the following options with sysctl vm.dirty_background_ratio = 5 # you start to write to disk as soon as 5% of dirty cache |
@zilexa |
hi @rakshasa I understand you're busy, did you happen to have time to look into this issue or have any reccomendations with regards to a permanent fix? |
hi @rakshasa we're rapidly nearing 6 years of this issue being open and from reading this issue, we don't really know what your plans are. i think we can all appreciate your work through the years (i certainly do) and I really do hate to badger you, however it feels like i/we have no other option. you owe us nothing, but i think i can speak for everyone when i say that some communication on this would be hugely appreciated. for example, if you need help with a certain issue it might spur people to contribute. if it's a monetary issue, people might donate. the silence really is deafening though - please do respond! |
If an issue can be fixed but is not yet fixed, it should stay open. If the author cannot for whatever reason fix the issue, the issue can just be marked with label "help needed" / "pr welcome" or similar and that's it. |
I fixed the issue on my seedbox by switching to madvise instead of direct paging. Dell Virtual disk Raid 0 HDD drive. Why I wanted to post was more as a warning after reading people wanting to experiment with read_ahead_kb. If you change the default value (to something too big?), you may end up with rtorrent misreporting uploaded data/ratio to the tracker. Don't think you can ratio cheat with it, the reported value/data is less than the actual uploaded data. If you want to toy around with read_ahead_kb, you can decide what value to use for the setting/buffer using this command:
The command will leave read_ahead_kb with the last used value, 16384, so watch out for that. |
Can anyone confirm if the two PR's opened by @stickz do actually make a difference when the minimum speed set for preloading is higher than the slower seeds? |
I'm not an expert at all, but I found this thread that I think could be atleast slightly relevant to the issue: https://qbforums.shiki.hu/viewtopic.php?t=9243 The user describes the same type of problem, and fixes it by updating/reinstalling his libtorrent(with a newer version I believe). I did not test this myself. |
That's a different client and libtorrent library that has nothing to do with rTorrent/libtorrent-rakshasa - There are 3 different libtorrent libraries that exist, the one that qBittorrent uses is https://www.libtorrent.org/ |
Thats too bad, thought maybe some of the information in the thread could be used, as it seems to be the same type of issue to me. Guess we'll just have to wait for a fix to come through here. |
rTorrent seems to be reading 4-6x more data than it's seeding. In this case I'm seeing 100-160MB/s read from rTorrent while it's only seeding about 20MB/s worth of data.
--- IOTOP
Total DISK READ : 161.06 M/s | Total DISK WRITE : 27.28 M/s
Actual DISK READ: 161.06 M/s | Actual DISK WRITE: 0.00 B/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
42685 be/4 debian-d 161.06 M/s 27.28 M/s 0.00 % 70.79 % rtorrent
--- rTorrent
[Throttle off/off KB] [Rate 21780.5/27685.2 KB] [Port: 65300] [U 357/0] [D 141/0] [H 0/4096] [S 21/700/65023] [F 5339/32768]
Thoughts?
The text was updated successfully, but these errors were encountered: