drops older gossip packets when load shedding (#13364) (#13423)

Gossip drops incoming packets when overloaded:
https://github.com/solana-labs/solana/blob/f6a73098a/core/src/cluster_info.rs#L2462-L2475
However newer packets are dropped in favor of the older ones.
This is probably not ideal as newer packets are more likely to contain
more recent data, so dropping them will keep the validator state
lagging.

(cherry picked from commit 7f4debdad5)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
This commit is contained in:
mergify[bot]
2020-11-05 18:30:00 +00:00
committed by GitHub
parent a2c32d7d0e
commit 98095b6f8d
2 changed files with 44 additions and 29 deletions

View File

@@ -89,6 +89,18 @@ impl<T: Clone + Default + Sized> Default for PinnedVec<T> {
}
}
impl<T: Clone + Default + Sized> Into<Vec<T>> for PinnedVec<T> {
fn into(mut self) -> Vec<T> {
if self.pinned {
unpin(self.x.as_mut_ptr());
self.pinned = false;
}
self.pinnable = false;
self.recycler = None;
std::mem::take(&mut self.x)
}
}
pub struct PinnedIter<'a, T>(std::slice::Iter<'a, T>);
pub struct PinnedIterMut<'a, T>(std::slice::IterMut<'a, T>);
@@ -109,6 +121,15 @@ impl<'a, T: Clone + Default + Sized> Iterator for PinnedIterMut<'a, T> {
}
}
impl<T: Clone + Default + Sized> IntoIterator for PinnedVec<T> {
type Item = T;
type IntoIter = std::vec::IntoIter<T>;
fn into_iter(self) -> Self::IntoIter {
<Self as Into<Vec<T>>>::into(self).into_iter()
}
}
impl<'a, T: Clone + Default + Sized> IntoIterator for &'a mut PinnedVec<T> {
type Item = &'a T;
type IntoIter = PinnedIter<'a, T>;
@@ -169,14 +190,8 @@ impl<T: Clone + Default + Send + Sized> IntoParallelIterator for PinnedVec<T> {
type Item = T;
type Iter = rayon::vec::IntoIter<T>;
fn into_par_iter(mut self) -> Self::Iter {
if self.pinned {
unpin(self.x.as_mut_ptr());
self.pinned = false;
}
self.pinnable = false;
self.recycler = None;
std::mem::take(&mut self.x).into_par_iter()
fn into_par_iter(self) -> Self::Iter {
<Self as Into<Vec<T>>>::into(self).into_par_iter()
}
}