feat(kad-dht): terminate query paths once the closest-K set is full#3539
Open
tabcat wants to merge 4 commits into
Open
feat(kad-dht): terminate query paths once the closest-K set is full#3539tabcat wants to merge 4 commits into
tabcat wants to merge 4 commits into
Conversation
Each disjoint path tracks the closest peers that have responded and stops querying peers that can no longer enter that set, the Kademlia/S-Kademlia termination condition. Prunes over-exploration at scale; at small topologies the gate never triggers, so existing tests are unchanged.
7 tasks
Add canAddKadId unit tests (incl. the equal-distance boundary) and a test that the enqueue-time gate skips the dialability check for pruned peers. Also reduce the gate comments and log the converged-path skip.
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.
Description
A query path keeps querying every peer closer than the one that returned it,
walking each disjoint path to exhaustion with no convergence check. This adds the
Kademlia/S-Kademlia termination condition: each path tracks the closest peers that
have responded, and once that set is full it stops at peers that can no longer
enter it - both when a peer comes off the queue, and before queuing a newly
discovered one (the latter also avoids the expensive dialability check for peers
it wouldn't query).
The effect is on a cold or sparse routing table, where a lookup explores widely; a
warm table converges in a step or two and the gate rarely fires. Measured against
the public Amino DHT, fresh node per lookup (table seeded only by bootstrap, ~5-7
peers):
At
kBucketSize = 20the gate never triggers on the small topologies in theexisting tests, so they're unchanged; it only prunes over-exploration at scale.
Part of #3536.
Change checklist