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

optimize numInbound count #960

Merged
merged 6 commits into from Jun 4, 2020
Merged

optimize numInbound count #960

merged 6 commits into from Jun 4, 2020

Conversation

Stebalien
Copy link
Member

We call this very frequently when computing our local addresses.

This PR also:

  • Unexports some exported types to reduce confusion.
  • Fixes a bug in the mock net.
  • Ensures we don't clobber an inbound observation with an outbound observation.

Review commit by commit.

Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

Generally LGTM. However, there are a few things that I'm not sure about and commented on that may just be due to my unfamiliarity with the intricacies of this code.

@@ -0,0 +1,35 @@
package identify
Copy link
Contributor

Choose a reason for hiding this comment

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

For posterity. why'd we move this to a new file/what is a reader supposed to think when distinguishing between obsaddr_test.go and observed_addr_test.go. It seems like these names are too similar.

Copy link
Member Author

Choose a reason for hiding this comment

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

This needed access to private types so I moved it from the identify_test package to the identify package.

Copy link
Contributor

Choose a reason for hiding this comment

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

seems reasonable. nbd, but maybe we should name the files differently?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably.

p2p/protocol/identify/obsaddr.go Show resolved Hide resolved
p2p/protocol/identify/obsaddr_test.go Show resolved Hide resolved
p2p/protocol/identify/obsaddr_test.go Outdated Show resolved Hide resolved
p2p/protocol/identify/obsaddr_test.go Outdated Show resolved Hide resolved
p2p/protocol/identify/obsaddr.go Outdated Show resolved Hide resolved
// Don't trump an outbound observation with an inbound
// one.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean the opposite? You're saying to mark as inbound if it was, or is currently inbound.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the wording here is just throwing me off (maybe just tired 😃). Maybe something like "Observation is considered inbound if the peer ever gave it to us as an inbound observation"

@aschmahmann
Copy link
Contributor

Seems reasonable, although we need to figure out why CI is failing here

We don't use and/or expose these anyways. Making them private makes it easier to
reason about their state.
We prefer addresses from inbound connections. We don't want outbound connections
to hide these perfectly good addresses.
We call this _very_ frequently when computing our local addresses.
@Stebalien
Copy link
Member Author

Well, the comment above the failure is:

// this feels a little sketchy, but its probably okay

Ant it appears to be very rare.

@Stebalien Stebalien deleted the fix/obs-perf branch June 4, 2020 22:08
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

3 participants