Skip to content
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

Simplify updating queue entries #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kannibalox
Copy link

The erase/insert pattern can be replaced by a single method that updates an existing entry's timer, or inserting if it doesn't exist.

This primary goal was to reduce CPU usage when handling incoming connections on large instances, but since the optimization was pretty generic it's been applied to many places.

The erase/insert pattern can be replaced by a single method that
updates an existing entry's timer, or inserting if it doesn't exist.

This primary goal was to reduce CPU usage when handling incoming
connections on large instances, but since the optimization was pretty
generic it's been applied to many places.
@stickz
Copy link
Contributor

stickz commented Mar 24, 2024

Great Job @kannibalox. This pull request is 100% stable and greatly increases the number of peers rTorrent can process! It will allow over 10 gigabits to be pushed through rTorrent, provided the solid state hardware and system memory specs exist.

Is there any chance you could reduce CPU usage for downloading? I can't obtain any faster than 2 gigabits because it's CPU bound. I believe the problem is related to the way libtorrent rakshasa manages the pieces.

@kannibalox
Copy link
Author

Is there any chance you could reduce CPU usage for downloading? I can't obtain any faster than 2 gigabits because it's CPU bound. I believe the problem is related to the way libtorrent rakshasa manages the pieces.

I did find a couple other things that could be optimized, but without a profile of actual usage from perf record or something similar, it's hard to know where the busiest parts are, and I didn't want to flood the repo with lots of micro-optimization PRs

@stickz
Copy link
Contributor

stickz commented Mar 31, 2024

I did find a couple other things that could be optimized, but without a profile of actual usage from perf record or something similar, it's hard to know where the busiest parts are, and I didn't want to flood the repo with lots of micro-optimization PRs

@kannibalox Please send me an email.
I have what you need. I don't want to post sensitive data here.
I recorded 100% CPU usage at 4.3ghz downloading at 2gbits.

@stickz
Copy link
Contributor

stickz commented Mar 31, 2024

@kannibalox Thank you for your email. I have determined the download delegator which decides the pieces to queue is responsible for the high CPU usage. There are multiple std::find_if search patterns being called very rapidly at 2gbps.
https://github.com/rakshasa/libtorrent/blob/master/src/download/delegator.cc

stickz added a commit to stickz/rTorrent-seedbox that referenced this pull request Apr 9, 2024
From kannibalox:
rakshasa/libtorrent#248

The erase/insert pattern can be replaced by a single method that updates an existing entry's timer, or inserting if it doesn't exist.

This primary goal was to reduce CPU usage when handling incoming connections on large instances, but since the optimization was pretty generic it's been applied to many places.

Notes from stickz: This patch leads to higher throughput when seeding torrents. It greatly reduces the CPU usage of the rTorrent software. It is 100% stable and there are no downsizes to using the patch. Tracker updates are also performed faster.
stickz added a commit to stickz/rTorrent-seedbox that referenced this pull request Apr 9, 2024
From kannibalox:
rakshasa/libtorrent#248

The erase/insert pattern can be replaced by a single method that updates an existing entry's timer, or inserting if it doesn't exist.

This primary goal was to reduce CPU usage when handling incoming connections on large instances, but since the optimization was pretty generic it's been applied to many places.

Notes from stickz: This patch leads to higher throughput when seeding torrents. It greatly reduces the CPU usage of the rTorrent software. It is 100% stable and there are no downsides to using the patch. Tracker updates are also performed faster.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants