struct DeferredAcks {
by_poly: HashMap<PolynomialIndex, Vec<(OffchainPublicKey, HalfKeyChallenge, HalfKey)>>,
total: usize,
drained: bool,
}Expand description
Deferred acknowledgements for one cycle, drained in one shot when its part builders install.
Plain Vecs under one mutex rather than nested caches: a bucket is only ever appended to and
then drained whole, so per-entry cache bookkeeping (and its ~200 B overhead per entry) buys
nothing. The mutex serialises deferrals within one cycle only, and deferral is O(1) work off
the steady-state path.
Fields§
§by_poly: HashMap<PolynomialIndex, Vec<(OffchainPublicKey, HalfKeyChallenge, HalfKey)>>§total: usizeRunning sum of the by_poly lengths, maintained so the per-cycle cap is an O(1) check.
Recomputing it would walk every sub-bucket inside the mutex on every deferral, and there
can be one sub-bucket per entry: filling a bucket to
MAX_DEFERRED_ACKS_PER_CYCLE would then cost ~33M map-entry visits, on the path every
acknowledgement takes during the commitment window. The invariant
total == by_poly.values().map(Vec::len).sum() has one increment site and one reset site,
both under this mutex.
drained: boolSet by the one drain this bucket will ever get, in the same critical section as the take.
A bucket is reachable through two routes: the pending_acks key, and an Arc a
defer_ack already holds. The drain removes the first but
cannot revoke the second, so an append that lands after it would sit in a bucket nothing
will ever read again. This flag is how such an append notices — see
Deferral::Orphaned.
Trait Implementations§
Source§impl Default for DeferredAcks
impl Default for DeferredAcks
Source§fn default() -> DeferredAcks
fn default() -> DeferredAcks
Auto Trait Implementations§
impl Freeze for DeferredAcks
impl RefUnwindSafe for DeferredAcks
impl Send for DeferredAcks
impl Sync for DeferredAcks
impl Unpin for DeferredAcks
impl UnsafeUnpin for DeferredAcks
impl UnwindSafe for DeferredAcks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more