Navigation Menu

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

Handling timers for repeat dispute participation requests #6901

Merged
merged 26 commits into from Mar 21, 2023

Conversation

BradleyOlson64
Copy link
Contributor

@BradleyOlson64 BradleyOlson64 commented Mar 16, 2023

This is a follow up to #6838 aiming to make the metric polkadot_parachain_dispute_participation_pipeline_durations more accurate.

Previously, if multiple participation requests were made for the same candidate then the older request would simply be dropped. But dropping the older request meant dropping its request timer as well. The pipeline duration metric only works properly if each request timer is dropped after we've participated in its corresponding dispute.

These changes fix the issue, keeping the oldest timer for each participation request alive and disposing of newer duplicate timers using stop_and_discard()

@BradleyOlson64 BradleyOlson64 self-assigned this Mar 16, 2023
@BradleyOlson64 BradleyOlson64 added 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. labels Mar 16, 2023
@BradleyOlson64 BradleyOlson64 requested review from tdimitrov and mrcnski and removed request for tdimitrov and mrcnski March 16, 2023 19:54
timer.stop_and_discard();
}
} else {
self.best_effort.insert(comparator, req);
Copy link
Member

Choose a reason for hiding this comment

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

You can avoid the double lookup via entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I'm missing something obvious, but here's the problem I see there. The intuitive pattern is something like:

self.priority.entry(comparator).or_insert(req);

But this pattern drops req without calling stop_and_discard() on its timer if there was an older request. This sends bad data to our metrics. I don't see a way to call stop_and_discard() without using a double lookup. 🤷‍♂️

Copy link

Choose a reason for hiding this comment

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

Can't you use or_insert_with to execute timer.stop_and_discard() first and then insert req?

Copy link
Member

Choose a reason for hiding this comment

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

you can also always pattern match on the Entry constructors and do whatever you need to do. See here for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your solution worked @eskimor Much appreciated!

@BradleyOlson64 BradleyOlson64 removed the request for review from tdimitrov March 17, 2023 22:39
Copy link
Contributor

@mrcnski mrcnski left a comment

Choose a reason for hiding this comment

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

Great docstring!

@BradleyOlson64
Copy link
Contributor Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit ad0c8a9 into master Mar 21, 2023
43 checks passed
@paritytech-processbot paritytech-processbot bot deleted the brad-issue-4393 branch March 21, 2023 00:55
ordian added a commit that referenced this pull request Mar 21, 2023
* master:
  kusama: enable dispute slashes (#5974)
  Introduce OpenGov into Polkadot (#6701)
  introduce new well known key (#6915)
  [CI] Add bootnode checking CI jobs (#6889)
  Bump parity-db (#6921)
  Handling timers for repeat dispute participation requests (#6901)
  [Companion #13634] keystore overhaul (iter2) (#6913)
  tweak some pattern matches to address a new clippy warning
  Bump ci-linux image for rust 1.68
  Revert "Update orchestra to the recent version (#6854)" (#6916)
  Deprecate Currency: Companion for #12951 (#6780)
  changelog: template fixup (#6907)
  [Companion #13615] Keystore overhaul (#6892)
  update weights (#6897)
  Fix approval voting test (#6898)
  parachains-runtime: Less cloning! (#6896)
  Testing Reversion Speed on Dispute Concluded Against (#6880)
  remove duplicated arm and fix version index (#6884)
ordian added a commit that referenced this pull request Mar 21, 2023
* master:
  kusama: enable dispute slashes (#5974)
  Introduce OpenGov into Polkadot (#6701)
  introduce new well known key (#6915)
  [CI] Add bootnode checking CI jobs (#6889)
  Bump parity-db (#6921)
  Handling timers for repeat dispute participation requests (#6901)
  [Companion #13634] keystore overhaul (iter2) (#6913)
  tweak some pattern matches to address a new clippy warning
  Bump ci-linux image for rust 1.68
  Revert "Update orchestra to the recent version (#6854)" (#6916)
  Deprecate Currency: Companion for #12951 (#6780)
  changelog: template fixup (#6907)
  [Companion #13615] Keystore overhaul (#6892)
  update weights (#6897)
  Fix approval voting test (#6898)
  parachains-runtime: Less cloning! (#6896)
  Testing Reversion Speed on Dispute Concluded Against (#6880)
  remove duplicated arm and fix version index (#6884)
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
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants