penalize duplicates #35

Merged
merged 2 commits into from Aug 27, 2016

Projects

None yet

2 participants

@arvidn
Contributor
arvidn commented Aug 27, 2016

The idea behind this patch is primarily to save upload bandwidth by sending fewer nodes back to duplicate requests from IPs. It only affects nodes that actually make it into the ping_queue, but any request from an IP that's in the queue receives 3 nodes, instead of the configured number (16 by default).

My experience is that at least a 1/3rd of all incoming requests fall into this category.

@arvidn arvidn commented on the diff Aug 27, 2016
src/main.cpp
@@ -920,6 +923,46 @@ struct router_thread
|| cmd == "get_peers"
|| cmd == "get")
{
+ insert_response inserted = insert_response::inserted;
@arvidn
arvidn Aug 27, 2016 Contributor

I flipped around sending the response and inserting into the queue, since inserting is what tells us whether it's a duplicate or not. note that I removed your duplicate check against the last source IP. did you get a lot of hits on that one? should I put it back?

@ssiloti
ssiloti Aug 27, 2016 Contributor

I didn't add that check you did, see 465def2.

@arvidn
arvidn Aug 27, 2016 Contributor

oh I see :)

@arvidn arvidn commented on the diff Aug 27, 2016
src/ping_queue.hpp
@@ -43,6 +43,13 @@ struct queued_node_t
int sock_idx;
};
+enum class insert_response
@arvidn
arvidn Aug 27, 2016 Contributor

maybe this enum is poorly named

@ssiloti
Contributor
ssiloti commented Aug 27, 2016

lgtm

@arvidn arvidn merged commit ad72eef into bittorrent:master Aug 27, 2016
@arvidn arvidn deleted the arvidn:penalize-duplicates branch Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment