Reduce goroutines amount: Client-level trackers#17765
Merged
AskAlexSharov merged 14 commits intomainfrom Nov 14, 2025
Merged
Conversation
4bd60ee to
b344b90
Compare
b344b90 to
e82c2ee
Compare
Contributor
Author
|
This should be ready. I want to make sure sync from scratch CI works now. I think it's only failed for unrelated reasons so far. |
Contributor
Author
|
The test failure is unrelated. |
Contributor
Author
|
Unrelated failure in Sync from Scratch CI I triggered: https://github.com/erigontech/erigon/actions/runs/19286631206/job/55148722521. |
Collaborator
currentely we have: |
Collaborator
|
pushed fix for win. |
AskAlexSharov
approved these changes
Nov 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#16699.
The changes are primarily in anacrolix/torrent, https://github.com/anacrolix/torrent/compare/d922d78d2e6135477b120daae537bf79a675d2c6..client-trackers.
Instead of firing off announces whenever we can, and maintaining a goroutine for every tracker and torrent combination, there's a dispatcher that reuses tracker announce clients, limits parallelism, and prioritizes announces to torrents that need them most, including doing things like avoiding announcing the same torrent to different trackers simultaneously unless there's nothing else to do, sending stop and completion events even when torrents are dropped, and avoiding announcing for torrents that have active webseed requests.
The impact for Erigon is that peers become available much sooner to the torrents that need them. Subjectively it goes from taking 5 mins or more to ~5-10s to start downloading from peers. There's also a possible issue around webseeds stalling if peers weren't present to tickle certain states that was fixed. I also added a hard webseed request stall fix after encountering it more often now that peers were more active on non-webseeding torrents.
There's a few optimizations that might be available down the road. The new indexing uses values instead of references in a lot of places, a careful strategy but probably results in a lot more cache and memory use than really necessary. It shouldn't show up in profiling as very large, but if it does there's plenty of easy stuff to improve once the concept has proven itself.
There's also a bunch of logging fixes in varous places. I expect to see a panic or two for edge cases I missed. There was a nagging one around some state not being propagated correctly but I think I've resolved that now.