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

[performance] cache domains after max retries in transport #884

Conversation

NyaaaWhatsUpDoc
Copy link
Member

Max retries are only reached if on HTTP server, DNS resolution or connection type errors. By caching these hostname failures we don't clog up the outoging request queue with likely failing requests.

Copy link
Contributor

@tsmethurst tsmethurst left a comment

Choose a reason for hiding this comment

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

Looks good. I've got a few questions but not really related to the implementation, just for my own info. Feel free to merge if you like :)

@@ -102,13 +110,13 @@ func (c *controller) NewTransport(pubKeyID string, privkey *rsa.PrivateKey) (Tra
}

// Cache this transport under pubkey
if !c.cache.Put(pubStr, transp) {
if !c.trspCache.Put(pubStr, transp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remind me under what conditions Put would return false?

// domain resolution type errors, so this cached result
// indicates this server is likely having issues.
if t.controller.badHosts.Has(host) {
return nil, errors.New("too many failed attempts")
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth making an error type for this so we can check for it? or nah?

// errors that are retried upon are server failure and
// domain resolution type errors, so this cached result
// indicates this server is likely having issues.
if t.controller.badHosts.Has(host) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Has call doesn't reset the ttl i assume?

@tsmethurst tsmethurst merged commit e58a6a2 into superseriousbusiness:main Oct 8, 2022
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