-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Reduce goroutines amount: Client-level trackers #17765
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
Conversation
4bd60ee to
b344b90
Compare
b344b90 to
e82c2ee
Compare
|
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. |
|
The test failure is unrelated. |
|
Unrelated failure in Sync from Scratch CI I triggered: https://github.com/erigontech/erigon/actions/runs/19286631206/job/55148722521. |
currentely we have: |
|
pushed fix for win. |
#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.