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

Move routing table exchange to another thread #5089

Merged
merged 5 commits into from
Nov 9, 2021
Merged

Move routing table exchange to another thread #5089

merged 5 commits into from
Nov 9, 2021

Conversation

pmnoxx
Copy link
Contributor

@pmnoxx pmnoxx commented Oct 27, 2021

In this PR we will creating copy of routing table to another thread.

This is related to #4859

Summary:

  • PeerManager no longer has copy of edges_info, instead it only stores list of edges to peers that it is/was connected to local_edges_info
  • Removed usage of edges in PeerManager that were stored in edges_info
  • Computation of peer_forwarding is done in RoutingTableActor, PeerManager gets it from another thread every second / tests now use RoutingTableActor instead of RoutingTable struct
  • moved pub raw_graph: Graph, and a few other data structures to RoutingTableActor
  • Removed adv_get_routing_table_new from jsonrpc server. Now, routing table is only stored in one place, so this method is no longer needed
  • Added code/struct comments

Closes #4859

@bowenwang1996 bowenwang1996 requested a review from mm-near October 27, 2021 12:25
Copy link
Contributor

@mm-near mm-near left a comment

Choose a reason for hiding this comment

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

First part of the review. I'll add more comments tomorrow.

nearcore/src/lib.rs Outdated Show resolved Hide resolved
nearcore/src/lib.rs Outdated Show resolved Hide resolved
chain/network/src/test_utils.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/jsonrpc/test-utils/src/lib.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing.rs Outdated Show resolved Hide resolved
@pmnoxx pmnoxx marked this pull request as ready for review October 28, 2021 11:22
@pmnoxx pmnoxx requested review from mm-near and matklad October 28, 2021 11:22
chain/jsonrpc/Cargo.toml Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
chain/network/src/routing_table_actor.rs Outdated Show resolved Hide resolved
@pmnoxx
Copy link
Contributor Author

pmnoxx commented Oct 28, 2021

chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
chain/network/src/peer_manager.rs Outdated Show resolved Hide resolved
@pmnoxx
Copy link
Contributor Author

pmnoxx commented Oct 28, 2021

I moved out some of the changes to: #5097

@pmnoxx pmnoxx self-assigned this Oct 29, 2021
@pmnoxx pmnoxx linked an issue Oct 29, 2021 that may be closed by this pull request
3 tasks
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.

@mm-near please review

@pmnoxx
Copy link
Contributor Author

pmnoxx commented Nov 1, 2021

@mm-near If you think it will make reviewing easier, I can extract the refactoring mentioned in summary to a separate change.

@pmnoxx
Copy link
Contributor Author

pmnoxx commented Nov 2, 2021

@mm-near @bowenwang1996 I added summary to the first post in the PR, I hope it helps.

near-bulldozer bot pushed a commit that referenced this pull request Nov 7, 2021
We should refactor network code, before #5089

- This refactoring doesn't contain any code changes, only methods/attributes are renamed to better names
- All changes are extracted from #5089, this was done to keep that PR smaller. This will cause merge conflicts, but it's better to extract syntax only changes to make #5089 easier to review.

Here is design doc for changes planned (https://docs.google.com/document/d/1FV3oyMRo52EQAgYroVd6Ws-5-ylkLSTdMOstY-IdL-M/edit?usp=sharing)
@pmnoxx pmnoxx added A-network Area: Network C-enhancement Category: An issue proposing an enhancement or a PR with one. T-core Team: issues relevant to the core team labels Nov 8, 2021
near-bulldozer bot pushed a commit that referenced this pull request Nov 8, 2021
…5163)

In preparation for moving routing table computation to `RoutingTableActor`, we should move  handling `start_routing_table_syncv2` from `PeerManager` to `RoutingTableActor` first.

Related to #5138
Change extracted from #5089, to make that PR shorter.
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.

@mm-near please review this PR

pytest/tests/sanity/routing_table_sync.py Show resolved Hide resolved
near-bulldozer bot pushed a commit that referenced this pull request Nov 8, 2021
Make `RoutingTableActor` use Context instead of `SyncContext`.
`SyncContext` is meant to be used in situations, where someone wants to start multiple instances of actors, each one separate thread. We only have one instance, and the code wouldn't work with multiple instances, so we are changing `SyncContext` to `Context`, to make reading code less confusion.


Additional changes:
- Add `edge_verifier_pool` to `RoutingTableActor` (for #5089)
- Rename `routing_table_pool` to `routing_table_addr`

Changes are extracted from #5089 to make it easier to review.
near-bulldozer bot pushed a commit that referenced this pull request Nov 9, 2021
Add new features to routing table actor.

- do edge pruning (not used yet)
- store all edges in `edges_info`
-  `StartRoutingTableSync` (handling first message of protocol_feature_routing_exchange_algorithm)  (not yet used)
-  `RoutingTableUpdate` (updating routing table and maybe pruning edges) (not yet used)
-  `AddVerifiedEdges` - adds verified edges and updates stats (Similar to `AddEdges`, but does more) (not yet used)

This is done to split #5089 into smaller pieces.
This should be reviewed after #5159, as this PR also includes changes in that request.
@pmnoxx
Copy link
Contributor Author

pmnoxx commented Nov 9, 2021

@mm-near Can you take a look? This PR is much smaller after splitting it 6 times.

@pmnoxx pmnoxx requested a review from bowenwang1996 November 9, 2021 03:18
@pmnoxx
Copy link
Contributor Author

pmnoxx commented Nov 9, 2021

@chefsale @frol @khorolets Can you take a look?

@pmnoxx
Copy link
Contributor Author

pmnoxx commented Nov 9, 2021

@chefsale @frol @khorolets Can you take a look?

@near-bulldozer near-bulldozer bot merged commit eae32db into near:master Nov 9, 2021
@pmnoxx pmnoxx deleted the piotr-move-routing-table-exchange-to-another-thread-pt2 branch November 9, 2021 18:21
pmnoxx added a commit that referenced this pull request Nov 20, 2021
Make `RoutingTableActor` use Context instead of `SyncContext`.
`SyncContext` is meant to be used in situations, where someone wants to start multiple instances of actors, each one separate thread. We only have one instance, and the code wouldn't work with multiple instances, so we are changing `SyncContext` to `Context`, to make reading code less confusion.


Additional changes:
- Add `edge_verifier_pool` to `RoutingTableActor` (for #5089)
- Rename `routing_table_pool` to `routing_table_addr`

Changes are extracted from #5089 to make it easier to review.
pmnoxx added a commit that referenced this pull request Nov 20, 2021
Add new features to routing table actor.

- do edge pruning (not used yet)
- store all edges in `edges_info`
-  `StartRoutingTableSync` (handling first message of protocol_feature_routing_exchange_algorithm)  (not yet used)
-  `RoutingTableUpdate` (updating routing table and maybe pruning edges) (not yet used)
-  `AddVerifiedEdges` - adds verified edges and updates stats (Similar to `AddEdges`, but does more) (not yet used)

This is done to split #5089 into smaller pieces.
This should be reviewed after #5159, as this PR also includes changes in that request.
@pmnoxx pmnoxx added the C-epic Category: an epic label Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network C-enhancement Category: An issue proposing an enhancement or a PR with one. C-epic Category: an epic T-core Team: issues relevant to the core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop using non monotous chrono::DateTime Move old exchange routing table to new thread
5 participants