Skip to content

Commit 703677b

Browse files
authored
precomputes Turbine trees speculatively before shreds arrive (anza-xyz#5014)
The commit maintains number of shreds observed in each slot within a rolling window. If the channel is empty and there are no shreds to retransmit, it uses the idle cycles to speculatively precompute turbine tree for slots which have received most number of shreds within the rolling window.
1 parent 760b6fc commit 703677b

File tree

6 files changed

+678
-89
lines changed

6 files changed

+678
-89
lines changed

ledger/src/shred.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub struct ShredId(Slot, /*shred index:*/ u32, ShredType);
276276

277277
impl ShredId {
278278
#[inline]
279-
pub(crate) fn new(slot: Slot, index: u32, shred_type: ShredType) -> ShredId {
279+
pub fn new(slot: Slot, index: u32, shred_type: ShredType) -> ShredId {
280280
ShredId(slot, index, shred_type)
281281
}
282282

@@ -285,6 +285,16 @@ impl ShredId {
285285
self.0
286286
}
287287

288+
#[inline]
289+
pub fn index(&self) -> u32 {
290+
self.1
291+
}
292+
293+
#[inline]
294+
pub fn shred_type(&self) -> ShredType {
295+
self.2
296+
}
297+
288298
#[inline]
289299
pub(crate) fn unpack(&self) -> (Slot, /*shred index:*/ u32, ShredType) {
290300
(self.0, self.1, self.2)

ledger/src/shred/wire.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ pub(super) fn get_parent_offset(shred: &[u8]) -> Option<u16> {
112112
Some(u16::from_le_bytes(bytes))
113113
}
114114

115-
// Returns DataShredHeader.flags.
115+
// Returns DataShredHeader.flags if the shred is data.
116+
// Returns Error::InvalidShredType for coding shreds.
116117
#[inline]
117-
pub(crate) fn get_flags(shred: &[u8]) -> Result<ShredFlags, Error> {
118+
pub fn get_flags(shred: &[u8]) -> Result<ShredFlags, Error> {
118119
match get_shred_type(shred)? {
119120
ShredType::Code => Err(Error::InvalidShredType),
120121
ShredType::Data => {

0 commit comments

Comments
 (0)