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

PeerSubscribers now specify what messages they are interested in #1137

Conversation

pipermerriam
Copy link
Member

@pipermerriam pipermerriam commented Aug 1, 2018

What was wrong?

fixes #1055

How was it fixed?

All PeerSubscriber classes must now implement a subscription_msg_types which defines which types of messages it will add to it's queue. Any message not the specified types is discarded. Including the base p2p.protocol.Command in the list results in all messages being included in the queue.

Cute Animal Picture

wenn21048138

@pipermerriam
Copy link
Member Author

@gsalgado I still want to make some changes to the API so hold off on reviewing for now. Sorry for the pre-mature request.

@pipermerriam pipermerriam force-pushed the piper/filters-for-peer-pool-subscribers branch from 2ce6ef8 to edcb4d2 Compare August 1, 2018 22:04
@pipermerriam
Copy link
Member Author

pipermerriam commented Aug 1, 2018

ok, ready for review, however, some brief testing shows this needs a bit more attention.

@pipermerriam
Copy link
Member Author

Two things

  1. Something on master recently is causing a significant performance hit. I'm seeing block import times on master up to around 45s or more for batches of 192 blocks.
  2. This PR seems to provide a measurable performance increase, as block import times on this branch are closer to the 30s mark.

Will investigate further tomorrow but wanted to make note of it here.

command which is not in this set will not be passed to this subscriber.

The base command class `p2p.protocol.Command` can be used to enable
**all** command types.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be worth mentioning that only sub-proto messages are delivered this way -- the base protocol ones are handled exclusively at the peer level

p2p/peer.py Outdated
peer, cmd, _ = msg

if not self.is_subscription_command(type(cmd)):
if hasattr(self, 'logger'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which subscribers don't provide a logger? Should we change them so they do?

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 is actually for the tests. The PeerSubscriber itself doesn't provide a logger. I'll remove this and change the ones in the test to have loggers.

@pipermerriam pipermerriam merged commit bf1d3c2 into ethereum:master Aug 3, 2018
@pipermerriam pipermerriam deleted the piper/filters-for-peer-pool-subscribers branch August 3, 2018 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider allowing PeerPoolSubscribers to specify types of messages they're not interested in
2 participants