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

Add metrics timing message passing from OverseerSubsystemContext to Overseer::route_message#2201

Merged
coriolinus merged 9 commits intomasterfrom
prgn-message-passing-metrics
Jan 6, 2021
Merged

Add metrics timing message passing from OverseerSubsystemContext to Overseer::route_message#2201
coriolinus merged 9 commits intomasterfrom
prgn-message-passing-metrics

Conversation

@coriolinus
Copy link
Contributor

Closes #2186.

This timer only exists / logs a fraction of the time (configurable
by `MESSAGE_TIMER_METRIC_CAPTURE_RATE`). When it exists, it tracks
the span between the `OverSubsystemContext` receiving the message
and its receipt in `Overseer::run`.
This should be more accurate; it ensures that the timer runs
at least as long as that function. As `route_message` is async,
it may not actually run for some time after it is called (or ever).
@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Jan 5, 2021
The previous impl using `from_entropy` depends on the `getrandom`
crate, which uses the system entropy source, and which does not
work on `wasm32-unknown-unknown` because it wants to fall back to
a JS implementation which we can't assume exists.

This impl depends only on `rand::thread_rng`, which has no documentation
stating that it's similarly limited.
This deserves a bit of explanation, as the motivating issue explicitly
requested randomness. In short, it's hard to get randomness to compile
for `wasm32-unknown-unknown` because that is explicitly intended to be
as deterministic as practical. Additionally, even though it would never
be used for consensus purposes, it still felt offputting to intentionally
introduce randomness into a node's operations. Except, it wasn't really
random, either: it was a deterministic PRNG varying only in its state,
and getting the state to work right for that target would have required
initializing from a constant.

Given that it was a deterministic sequence anyway, it seemed much simpler
and more explicit to simply select one of each N messages instead of
attempting any kind of realistic randomness.
@coriolinus
Copy link
Contributor Author

Promoting the commit message from 0ab8594:

This deserves a bit of explanation, as the motivating issue explicitly
requested randomness. In short, it's hard to get randomness to compile
for wasm32-unknown-unknown because that is explicitly intended to be
as deterministic as practical. Additionally, even though it would never
be used for consensus purposes, it still felt offputting to intentionally
introduce randomness into a node's operations. Except, it wasn't really
random, either: it was a deterministic PRNG varying only in its state,
and getting the state to work right for that target would have required
initializing from a constant.

Given that it was a deterministic sequence anyway, it seemed much simpler
and more explicit to simply select one of each N messages instead of
attempting any kind of realistic randomness.

@coriolinus coriolinus 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. labels Jan 6, 2021
This partially reverts commit 0ab8594.

`oorandom` is much lighter than the previous `rand`-based implementation,
which makes this easier to work with.

This implementation gives each subsystem and each child RNG a distinct
increment, which should ensure they produce distinct streams of values.
@coriolinus
Copy link
Contributor Author

Note to reviewers: the oorandom::Rand32 implementation added in ea59309 is not suitable for cryptographic purposes. That should be fine because we do not use it for cryptographic purposes.

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

LGTM!

@coriolinus
Copy link
Contributor Author

bot merge

@ghost
Copy link

ghost commented Jan 6, 2021

Missing process info; check that the PR belongs to a project column.

Merge can be attempted if:

  • The PR has approval from two core-devs (or one if the PR is labelled insubstantial).
  • The PR has approval from a member of substrateteamleads.
  • The PR is attached to a project column and has approval from the project owner.

See https://github.com/paritytech/parity-processbot#faq

@coriolinus coriolinus merged commit 004dc50 into master Jan 6, 2021
@coriolinus coriolinus deleted the prgn-message-passing-metrics branch January 6, 2021 13:25
ordian added a commit that referenced this pull request Jan 6, 2021
* master:
  added new bootnode to chain spec's (#2204)
  Add metrics timing message passing from OverseerSubsystemContext to Overseer::route_message (#2201)
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.

Metrics: track time for messages to be placed into recipient channel

2 participants