-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Conversation
/// Timer handle for each participation request. Stored to measure full request | ||
/// completion time. Optimally these would have been stored in the participation | ||
/// request itself, but HistogramTimer doesn't implement the Clone trait. | ||
request_timers: BTreeMap<CandidateComparator, Option<prometheus::HistogramTimer>>, |
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.
HistogramTimer doesn't implement the Clone trait.
I think you can put it behind a smart pointer like Rc
. Might simplify the code. 🙂
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.
Rc
doesn't work because we have multithreaded tokio runtime, we would need Arc
.
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.
Placed the timer in ParticipationRequest
. It does indeed simplify the changes 👍 Please check the refactor when you have a moment!
/// Timer handle for each participation request. Stored to measure full request | ||
/// completion time. Optimally these would have been stored in the participation | ||
/// request itself, but HistogramTimer doesn't implement the Clone trait. | ||
request_timers: BTreeMap<CandidateComparator, Option<prometheus::HistogramTimer>>, |
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.
Rc
doesn't work because we have multithreaded tokio runtime, we would need Arc
.
@@ -221,12 +221,12 @@ impl metrics::Metrics for Metrics { | |||
)?, | |||
registry, | |||
)?, | |||
priority_queue_size: prometheus::register( | |||
participation_priority_queue_size: prometheus::register( | |||
prometheus::Gauge::new("polkadot_parachain_dispute_priority_queue_size", |
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.
nit: Should the metric names be updated to match the new variable names? e.g. "polkadot_parachain_dispute_participation_priority_queue_size"
let request_timer = Arc::new(self.metrics.time_participation_pipeline()); | ||
let r = self | ||
.participation | ||
.queue_participation( | ||
ctx, | ||
priority, | ||
ParticipationRequest::new(new_state.candidate_receipt().clone(), session), | ||
ParticipationRequest::new(new_state.candidate_receipt().clone(), session, request_timer), |
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.
My first reaction was maybe request_timer
can be initialized in ParticipationRequest::new
. But after looking at it, doing it like this instead of hiding it inside ParticipationRequest::new
makes it more explicit that we are starting a timer here. 👍
if &self.candidate_receipt == other.candidate_receipt() && | ||
&self.candidate_hash == other.candidate_hash() && | ||
self.session == other.session() |
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.
I would destructure self
into its fields, so that if a field is ever added in the future we don't forget to add it to the comparison here. It would look something like this:
let ParticipationRequest { candidate_receipt, candidate_hash, session, _request_timer } = self;
/* do the comparison */
Credit to @eskimor for teaching me this!
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.
nit: Also, instead of if cond { return true; } false
, you can simplify it to just cond
. :) I think clippy should warn about this.
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.
Credit to @eskimor for teaching me this!
+1 :)
// eq. This helper checks whether all other fields are equal, | ||
// which is sufficient. | ||
#[cfg(test)] | ||
pub fn functionally_equal(&self, other: ParticipationRequest) -> bool { |
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.
nit: I had an internal struggle about this, but I think we should just impl eq
on this type. I believe that already implies functional equality. I read the docs for PartialEq
, and there is no restriction mentioned about having to include every field in the equality comparison.
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.
Interesting! I hadn't thought of it that way. But it does make sense. I shall make changes.
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.
Looks good! Left some nits, but nothing blocking.
@@ -235,7 +241,8 @@ impl Participation { | |||
recent_head: Hash, | |||
) -> FatalResult<()> { | |||
while self.running_participations.len() < MAX_PARALLEL_PARTICIPATIONS { | |||
if let Some(req) = self.queue.dequeue() { | |||
let maybe_req = self.queue.dequeue(); |
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.
nit: Why we need this variable?
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.
Good catch! That was an artifact from a discarded implementation.
// which is sufficient. | ||
#[cfg(test)] | ||
pub fn functionally_equal(&self, other: ParticipationRequest) -> bool { | ||
if &self.candidate_receipt == other.candidate_receipt() && |
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.
I'd implement this by destructuring (unless it's not possible due to something I'm not seeing right now). This way we'll get a compilation error if a new field is added to the struct.
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.
Also can't we implement std::cmp::PartialEq::eq
for ParticipationRequest
so that we have got a bit nicer looking syntax?
Good job! Just some small remarks from me. |
I just saw that @mrcnski has already left comments similar to mine. Sorry for the double posting :/ |
This reverts commit 02e5608.
bot merge |
* master: (50 commits) Issue 4393: Correcting Unnecessary Use of Arc (#6882) Companion for #13287 (#6655) timestamp ci job logs (#6890) Release parachain host API v4 (#6885) polkadot companion: #13128 (Pools commission) (#6264) companion for #13555 (#6842) Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#6600) Bump bumpalo from 3.8.0 to 3.12.0 (#6599) Bump git2 from 0.16.0 to 0.16.1 (#6601) Council as SpendOrigin (#6877) PVF: Document that preparation cannot lead to disputes (#6873) Sync versions with current release (0.9.39) (#6875) Companion for paritytech/substrate#13592 (#6869) Update orchestra to the recent version (#6854) Delete unused Cargo.lock (#6870) Remove use of Store trait (#6835) Companion for Substrate #13564 (#6845) Adding Dispute Participation Metrics (#6838) Update `substrate` to 48e7cb1 (#6851) Move PVF timeouts to executor environment parameters (#6823) ...
…slashing-client * ao-past-session-slashing-runtime: (23 commits) Issue 4393: Correcting Unnecessary Use of Arc (#6882) Companion for #13287 (#6655) timestamp ci job logs (#6890) Release parachain host API v4 (#6885) polkadot companion: #13128 (Pools commission) (#6264) companion for #13555 (#6842) Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#6600) Bump bumpalo from 3.8.0 to 3.12.0 (#6599) Bump git2 from 0.16.0 to 0.16.1 (#6601) Council as SpendOrigin (#6877) PVF: Document that preparation cannot lead to disputes (#6873) Sync versions with current release (0.9.39) (#6875) Companion for paritytech/substrate#13592 (#6869) Update orchestra to the recent version (#6854) Delete unused Cargo.lock (#6870) Remove use of Store trait (#6835) Companion for Substrate #13564 (#6845) Adding Dispute Participation Metrics (#6838) Update `substrate` to 48e7cb1 (#6851) Move PVF timeouts to executor environment parameters (#6823) ...
Per issue #4393
We should have metrics on the following: