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

add ActiveLeavesUpdate, remove StartWork, StopWork #1458

Merged
merged 8 commits into from
Jul 27, 2020

Conversation

coriolinus
Copy link
Contributor

Closes #1418.

@coriolinus coriolinus added A3-in_progress Pull request is in progress. No review needed at this stage. 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. labels Jul 23, 2020
Note: this does not yet convert the tests; some of the tests now freeze:

test tests::overseer_start_stop_works ... test tests::overseer_start_stop_works has been running for over 60 seconds
test tests::overseer_finalize_works ... test tests::overseer_finalize_works has been running for over 60 seconds
@coriolinus coriolinus marked this pull request as ready for review July 24, 2020 09:54
@coriolinus coriolinus requested review from rphmeier and montekki July 24, 2020 09:54
@github-actions github-actions bot 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 Jul 24, 2020
Comment on lines 1047 to 1070
trait Equivalent {
fn equiv(&self, other: &Self) -> bool;
}

impl Equivalent for ActiveLeavesUpdate {
fn equiv(&self, other: &Self) -> bool {
self.activated.iter().collect::<HashSet<_>>() == other.activated.iter().collect::<HashSet<_>>() &&
self.deactivated.iter().collect::<HashSet<_>>() == other.deactivated.iter().collect::<HashSet<_>>()
}
}

impl Equivalent for OverseerSignal {
fn equiv(&self, other: &Self) -> bool {
use OverseerSignal::{
ActiveLeaves,
Conclude,
};

match (self, other) {
(ActiveLeaves(lalu), ActiveLeaves(ralu)) => lalu.equiv(ralu),
(Conclude, Conclude) => true,
_ => false,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

although these are send around as Vecs essentially they are sets so it would probably be cleaner to just implement Eq on ActiveLeavesUpdate?

event_producers.values(),
&mut ctx,
).await {
log::warn!("Aborting - Failure to dispatch messages to overseer");
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably should use targets in all logging

if let Some(view_update)
= update_view(&peers, &live_heads, &mut net, &mut local_view).await?
{
if let Err(e) = dispatch_update_to_all(
Copy link
Contributor

Choose a reason for hiding this comment

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

One of the motivations of this change was to do only one update_view/dispatch_update_to_all when a new relay-parent comes in. That can be extracted to after the live_heads updates done by activated/deactivated.

///
/// If there are fewer than this number of slots, then we've wasted some stack space.
/// If there are greater than this number of slots, then we fall back to a heap vector.
const ACTIVE_LEAVES_SMALLVEC_CAPACITY: usize = 8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could maybe go even smaller, although I doubt it will impact performance or memory in any meaningful way

Copy link
Member

Choose a reason for hiding this comment

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

Note, that given vec optimizations like https://github.com/rust-lang/rust/pull/72227/files, using smallvec will only save us one allocation and indirection for small active sets. The hardest part is to come with a benchmark to justify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree that the right way to tune this is with a benchmark. Agree that it would be hard to write a really good benchmark for this. I think we all agree that 8 is a plausible size here anyway? For now, I think I'd prefer to just leave it than to spend the effort to determine the actual optimal size.

Copy link
Contributor

@rphmeier rphmeier left a comment

Choose a reason for hiding this comment

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

LGTM except for comments

This cleans up the code a bit and makes it easier in the future to
do the right thing when comparing ALUs.
@coriolinus coriolinus merged commit 12a0255 into master Jul 27, 2020
@coriolinus coriolinus deleted the prgn-active-leaves branch July 27, 2020 08:39
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace StartWork and StopWork with combined variant
4 participants