-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Handling timers for repeat dispute participation requests #6901
Conversation
timer.stop_and_discard(); | ||
} | ||
} else { | ||
self.best_effort.insert(comparator, req); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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. 🤷♂️
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great docstring!
bot merge |
* 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)
* 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)
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()