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

Piece cache fixes and improvements #3238

Merged
merged 5 commits into from
Nov 18, 2024
Merged

Piece cache fixes and improvements #3238

merged 5 commits into from
Nov 18, 2024

Conversation

nazar-pc
Copy link
Member

This both fixes and significantly improves piece cache sync and piece downloading more generally.

One bug was not storing free offset in case more than one cache stores the same piece index (usually caused by user manipulation with farms), test case was added to check this.

Significant slowdown was caused by faulty peers that initially claim to have a bunch of pieces, but then not returning them and instead returning closes peers, which in pathological cases meant farmer was sending thousands of individual requests to get pieces to a single peer one at a time, but was only getting closest peers back, meaning it was wasting a lot of time and to user that looked like downloading hanged even though it technically didn't.

I also improved piece cache sync performance by allowing to schedule more batches after previous batches partially completed, which helps with bandwidth saturation, this allowed me to download pieces as 100-250 Mbps speed most of the time, with higher limits can push closer to 800 Mbps. For higher utilization we'll need to introduce CLI option to increase memory usage by piece cache sync (right now constrained to use around 1GB).

Code contributor checklist:

@@ -647,6 +647,10 @@ where
if let Some(peers) = pieces_to_download.get_mut(&piece_index) {
peers.extend(Vec::from(closest_peers));
}

// No need to ask this peer again if they didn't have the piece we expected, or
// they claimed to have earlier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@nazar-pc nazar-pc added this pull request to the merge queue Nov 18, 2024
Merged via the queue into main with commit 8fe5849 Nov 18, 2024
16 checks passed
@nazar-pc nazar-pc deleted the piece-cache-fixes branch November 18, 2024 09:49
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.

2 participants