Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Split NetworkBridge and break cycles with Unbounded #2736

Merged
merged 30 commits into from
Mar 28, 2021

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Mar 28, 2021

Based on #2227

This also includes changes to the jobs system and subsystems making use of it to expose the SubsystemSender to each job.

Also:

  • Use send_unbounded_message in candidate backing to send statements to statement distribution
  • Use send_unbounded_message in approval voting to sent messages to approval distribution
  • Split network bridge into two tasks internally - one for handling incoming network notifications, and another for handling notifications from subsystems

@rphmeier rphmeier added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. labels Mar 28, 2021
@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Mar 28, 2021
@rphmeier rphmeier added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Mar 28, 2021
@rphmeier rphmeier marked this pull request as ready for review March 28, 2021 21:30
node/network/bridge/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +617 to +625
/// THIS IS A HACK. We need to ensure we never hold the mutex across a `.await` boundary
/// and `parking_lot` currently does not provide `Send`, which helps us enforce that.
/// If this breaks, we need to find another way to protect ourselves.
///
/// ```compile_fail
/// #use parking_lot::MutexGuard;
/// #fn is_send<T: Send>();
/// #is_send::<parking_lot::MutexGuard<'static, ()>();
/// ```
Copy link
Member

Choose a reason for hiding this comment

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

haven't look at the actual issue, but if we need an async-aware Mutex, there is https://docs.rs/futures/0.3.13/futures/lock/struct.Mutex.html?

Copy link
Contributor Author

@rphmeier rphmeier Mar 28, 2021

Choose a reason for hiding this comment

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

@ordian I think parking_lot::Mutex is fine here. To avoid deadlock the enforcement that we never use the mutex across a .await is helpful. It means we will never be waiting to unpark the thread for very long, and we never run into a situation where:

  • Side A is acquiring the mutex
  • Side B is holding the mutex and waiting for side A to drain a buffer

@rphmeier rphmeier changed the title Update jobs to use SubsystemSender and other subsystems to SubsystemSender Split NetworkBridge and break cycles with Unbounded Mar 28, 2021
@rphmeier rphmeier merged commit d23a6d5 into master Mar 28, 2021
@rphmeier rphmeier deleted the rh-network-bridge-split branch March 28, 2021 23:18
rphmeier added a commit that referenced this pull request Mar 28, 2021
* overseer: pass messages directly between subsystems

* test that message is held on to

* Update node/overseer/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <[email protected]>

* give every subsystem an unbounded sender too

* remove metered_channel::name

1. we don't provide good names
2. these names are never used anywhere

* unused mut

* remove unnecessary &mut

* subsystem unbounded_send

* remove unused MaybeTimer

We have channel size metrics that serve the same purpose better now and the implementation of message timing was pretty ugly.

* remove comment

* split up senders and receivers

* update metrics

* fix tests

* fix test subsystem context

* use SubsystemSender in jobs system now

* refactor of awful jobs code

* expose public `run` on JobSubsystem

* update candidate backing to new jobs & use unbounded

* bitfield signing

* candidate-selection

* provisioner

* approval voting: send unbounded for assignment/approvals

* async not needed

* begin bridge split

* split up network tasks into background worker

* port over network bridge

* Update node/network/bridge/src/lib.rs

Co-authored-by: Andronik Ordian <[email protected]>

* rename ValidationWorkerNotifications

Co-authored-by: Peter Goodspeed-Niklaus <[email protected]>
Co-authored-by: Andronik Ordian <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants