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

fix(network): Verify edge on separate thread #3145

Merged
merged 4 commits into from
Aug 12, 2020
Merged

Conversation

mfornet
Copy link
Member

@mfornet mfornet commented Aug 12, 2020

Sync message with large number of edges was blocking the PeerManagerActor. This was because verifying signature for each edge is a very expensive computation, for a message with 2K edges it takes ~6seconds. This computation was moved into a separate thread so the PeerManagerActor is not blocked.

TestPlan

Compile neard with delay_detector_enabled and run saturate_routing_table.py. Check that no messages block the PeerManagerActor for more than 50ms.

@gitpod-io
Copy link

gitpod-io bot commented Aug 12, 2020

Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

Choose a reason for hiding this comment

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

@mfornet is this enough to address the issue or do we also need to fix the schedule that recomputes the graph?

chain/chain/src/delay_detector.rs Outdated Show resolved Hide resolved
chain/network/src/peer.rs Outdated Show resolved Hide resolved
@@ -67,7 +67,7 @@ async def main():
assert response.Handshake.target_peer_id.data == bytes(
my_key_pair_nacl.verify_key)
assert response.Handshake.listen_port == nodes[0].addr()[1]
assert response.Handshake.version == handshake.Handshake.version
# assert response.Handshake.version == handshake.Handshake.version
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually that line shouldn't be removed, but it will fail until #3016 is merged. Will add a todo

@@ -0,0 +1,115 @@
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add this test to nightly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not yet, since it doesn't have a failure/successful condition.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was using this test for debugging, the condition will be probably based on logs from delay-detector, will add in next PR, since we need too push this ASAP

pytest/tests/stress/saturate_routing_table.py Outdated Show resolved Hide resolved
@mfornet
Copy link
Member Author

mfornet commented Aug 12, 2020

@mfornet is this enough to address the issue or do we also need to fix the schedule that recomputes the graph?

I'm also fixing the schedule that recompute the graph, but this PR fixes our current issue. Routing table update is very cheap even with ~6K edges, it takes less than 100ms.

@mfornet mfornet requested a review from bowenwang1996 August 12, 2020 05:09
@bowenwang1996
Copy link
Collaborator

@mfornet mfornet force-pushed the routing_table_threaded branch from 4045273 to 33b2269 Compare August 12, 2020 14:01
@codecov
Copy link

codecov bot commented Aug 12, 2020

Codecov Report

Merging #3145 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3145   +/-   ##
=======================================
  Coverage   87.34%   87.34%           
=======================================
  Files         212      212           
  Lines       41525    41525           
=======================================
  Hits        36270    36270           
  Misses       5255     5255           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bf2fb3...33b2269. Read the comment docs.

@mfornet mfornet merged commit f4c4489 into master Aug 12, 2020
@bowenwang1996 bowenwang1996 deleted the routing_table_threaded branch August 13, 2020 00:35
bowenwang1996 pushed a commit that referenced this pull request Aug 13, 2020
* fix(network): Verify edge on separate thread

* Address comments from bowen

* Fix compile error
bowenwang1996 pushed a commit that referenced this pull request Aug 13, 2020
* fix(network): Verify edge on separate thread

* Address comments from bowen

* Fix compile error
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.

3 participants