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

beefy: Increment metric and add extra log details #5075

Merged
merged 6 commits into from
Jul 20, 2024
Merged

Conversation

lexnv
Copy link
Contributor

@lexnv lexnv commented Jul 19, 2024

This PR increments the beefy metric wrt no peers to query justification from.
The metric is incremented when we submit a request to a known peer, however that peer failed to provide a valid response, and there are no further peers to query.

While at it, add a few extra details to identify the number of active peers and cached peers, together with the request error

Part of:

@lexnv lexnv added A1-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). R0-silent Changes should not be mentioned in any release notes I5-enhancement An additional feature request. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. labels Jul 19, 2024
@lexnv lexnv requested review from acatangiu and a team July 19, 2024 11:45
@lexnv lexnv self-assigned this Jul 19, 2024
Comment on lines 101 to 105
/// Returns the next peer from the peers cache, if available.
///
/// If the optional block number if provided, the peers cache is
/// repopulated from the live peers that have voted on higher block numbers.
fn try_next_peer(&mut self, reset_cache: Option<NumberFor<B>>) -> Option<PeerId> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This extra Option on this fn makes the code harder to read and reason about.

Is it making any difference in practice, at least? From what I see, all it achieves is locking once for longer rather than lock, release, lock.

Is this improving the behavior or lowering lock thrashing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, don't think the double-lock is having a huge impact on performance :) Just noticed it while digging for some metrics

When we lock release lock, there might be a chance that the peers we have in cache will disconnect in between the locks (and also get propagated to live peers). But I think we have enough info with the metrics and extra logs to catch these.

TLDR; lets keep the code simple :)

@lexnv lexnv changed the title beefy: Avoid double lock wrt live peers and cache reset beefy: Increment metric and add extra log details Jul 19, 2024
@bkchr bkchr added this pull request to the merge queue Jul 20, 2024
Merged via the queue into master with commit 9dcf6f1 Jul 20, 2024
160 of 161 checks passed
@bkchr bkchr deleted the lexnv/beefy-peers branch July 20, 2024 15:06
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
This PR increments the beefy metric wrt no peers to query justification
from.
The metric is incremented when we submit a request to a known peer,
however that peer failed to provide a valid response, and there are no
further peers to query.

While at it, add a few extra details to identify the number of active
peers and cached peers, together with the request error

Part of:
- paritytech#4985
- paritytech#4925

---------

Signed-off-by: Alexandru Vasile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A1-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I5-enhancement An additional feature request. R0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants