Git Product home page Git Product logo

Comments (4)

anacrolix avatar anacrolix commented on May 14, 2024

Oh dear, this looks non-trivial.

from torrent.

anacrolix avatar anacrolix commented on May 14, 2024

The first fix was bogus, see the later commit. Let me know how it goes.

from torrent.

dborzov avatar dborzov commented on May 14, 2024

Nice fix.
Do you think transaction.userOnResponse() should be called even if the query fails? Or was it just the easiest fix you thought about?

It seems to me that when the ping fails, userOnResponse() is called by transaction.close() which is called a couple of times (!) by transaction.timeout() which is called by transaction.timerCallback() the timer for which is assigned by transaction.startTimer() which is assigned by jitterDuration... this stuff looks pretty convoluted.

What was the logic there? What is the purpose of jitterDuration?

from torrent.

anacrolix avatar anacrolix commented on May 14, 2024

I don't actually recall why it works like that, I think it kind of evolved that way. I don't like how complex the response handling is, but it seemed justified at the time.

If you can think of a clearer way, I welcome it. It mainly went this path due to a need to reduce the number of goroutines. When I first wrote the DHT package, the server could easily jump to 200k goroutines, which wasn't compatible with the race detector.

jitterDuration implements slightly randomized timeouts, this is common in many network protocols to reduce the chance of network storms. That is, if a bunch of timeouts all trigger at the same time, a lot of outbound packets are sent too quickly. This occurs when you write a lot of packets over something like UDP, and then set identical timeouts to resend them all.

from torrent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.