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

Fix dht_announce_interval not being followed accurately in some cases #7476

Merged
merged 1 commit into from
Aug 24, 2023
Merged

Fix dht_announce_interval not being followed accurately in some cases #7476

merged 1 commit into from
Aug 24, 2023

Conversation

thrnz
Copy link
Contributor

@thrnz thrnz commented Jul 28, 2023

If I'm understanding the code correctly, announcing to the DHT seems to be done by cycling over all torrents with a delay of dht_announce_interval / total-number-of-torrents between each torrent - the idea being that announces are spread out evenly over the entire interval rather than everything being announced to the DHT all at once.

The delay between torrents seems to be calculated with a minimum of a single second and is rounded down. Depending on the total number of torrents, this might lead to the actual DHT announce interval being considerably shorter or longer than expected, especially with a larger number of torrents.

For example, the default dht_announce_interval of 900s with 451 torrents calculates a 1s delay, taking 451s to cycle through everything, or half as long as expected.

If there are more than dht_announce_interval torrents, the actual announce interval would be longer than expected. 1800 torrents would take 1800s to cycle through, twice as long as expected by default.

This change attempts to address this by calculating the delay between torrents using milliseconds instead of seconds, allowing sub-second delays when needed and preventing rounding issues.

This allows dht_announce_interval to be followed more accurately regardless of the total number of torrents
Copy link
Owner

@arvidn arvidn left a comment

Choose a reason for hiding this comment

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

great catch!

@arvidn arvidn added this to the 2.0.9 milestone Aug 23, 2023
@arvidn arvidn merged commit 42ca885 into arvidn:RC_2_0 Aug 24, 2023
39 of 42 checks passed
@thrnz thrnz deleted the dht_ms_interval branch August 24, 2023 06:21
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