Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

feat: limit the number of cold calls we can do#316

Merged
jacobheun merged 16 commits into
masterfrom
fix/cold-call
Apr 2, 2019
Merged

feat: limit the number of cold calls we can do#316
jacobheun merged 16 commits into
masterfrom
fix/cold-call

Conversation

@jacobheun

Copy link
Copy Markdown
Contributor

This creates a separate queue for "cold calls" (dials without a protocol). Applications typically do this on peer discovery to connect to new peers. This is to prevent flooding the normal queue, which needs to be prioritized for normal operations, with dials to new peers that may not respond.

This is a workaround, until we can improve the peer discovery system and connection/peer tagging, to allow for proper priority. Right now all dials are treated the same, which includes just creating a new stream on an existing connection. Existing connections and new dials should not be throttled the same way.

This also adds a very basic backoff to blacklisted peers. On its 5th blacklisting the peer will be added to the blacklist permanently. The backoff time may need to be increased before merging this

@ghost ghost assigned jacobheun Apr 1, 2019
@ghost ghost added the in progress label Apr 1, 2019
Comment thread src/dialer/queue.js Outdated
Comment thread src/dialer/queue.js
Comment thread src/dialer/queue.js
Comment thread src/dialer/queueManager.js
Comment thread src/dialer/queueManager.js Outdated
@jacobheun

Copy link
Copy Markdown
Contributor Author

Found an unrelated connection management issue, https://github.com/libp2p/js-libp2p-switch/issues/317, as I was running this against my local js-ipfs daemon logging out some stats.

@jacobheun jacobheun marked this pull request as ready for review April 2, 2019 10:03
@jacobheun jacobheun changed the title [WIP] feat: limit the number of cold calls we can do feat: limit the number of cold calls we can do Apr 2, 2019

@vasco-santos vasco-santos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great @jacobheun ! Nice work

Approved, but left a minor suggestion to consider

Comment thread src/dialer/queue.js
// Clear if the queue has reached max blacklist
if (dialQueue.blackListed === Infinity) {
dialQueue.abort()
delete this._queues[dialQueue.id]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think about doing this._queues[dialQueue.id] = undefined?

This is more efficient than deleting, but than we will need to verify that keys have a value when iterating the array, so I do not have a strong opinion here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since this is only running on a 15min interval I think the performance hit should be fairly insignificant and would avoid us needing to check values.

@dirkmc

dirkmc commented Apr 2, 2019

Copy link
Copy Markdown

LGTM 👍

@jacobheun jacobheun merged commit 4a543cb into master Apr 2, 2019
@ghost ghost removed the in progress label Apr 2, 2019
@vasco-santos vasco-santos deleted the fix/cold-call branch April 3, 2019 08:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants