Skip to content

Commit

Permalink
precomputes Turbine trees speculatively before shreds arrive
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
behzadnouri committed Feb 26, 2025
1 parent ce98b9b commit af3a2e3
Show file tree
Hide file tree
Showing 6 changed files with 676 additions and 89 deletions.
12 changes: 11 additions & 1 deletion ledger/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ pub struct ShredId(Slot, /*shred index:*/ u32, ShredType);

impl ShredId {
#[inline]
pub(crate) fn new(slot: Slot, index: u32, shred_type: ShredType) -> ShredId {
pub fn new(slot: Slot, index: u32, shred_type: ShredType) -> ShredId {
ShredId(slot, index, shred_type)
}

Expand All @@ -285,6 +285,16 @@ impl ShredId {
self.0
}

#[inline]
pub fn index(&self) -> u32 {
self.1
}

#[inline]
pub fn shred_type(&self) -> ShredType {
self.2
}

#[inline]
pub(crate) fn unpack(&self) -> (Slot, /*shred index:*/ u32, ShredType) {
(self.0, self.1, self.2)
Expand Down
5 changes: 3 additions & 2 deletions ledger/src/shred/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ pub(super) fn get_parent_offset(shred: &[u8]) -> Option<u16> {
Some(u16::from_le_bytes(bytes))
}

// Returns DataShredHeader.flags.
// Returns DataShredHeader.flags if the shred is data.
// Returns Error::InvalidShredType for coding shreds.
#[inline]
pub(crate) fn get_flags(shred: &[u8]) -> Result<ShredFlags, Error> {
pub fn get_flags(shred: &[u8]) -> Result<ShredFlags, Error> {
match get_shred_type(shred)? {
ShredType::Code => Err(Error::InvalidShredType),
ShredType::Data => {
Expand Down
Loading

0 comments on commit af3a2e3

Please sign in to comment.