This repository was archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable prefetch on the new engine (#164)
Co-authored-by: Keefe Liu <[email protected]>
Showing
10 changed files
with
216 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/// Trie stats. | ||
#[derive(Clone, Copy, Debug)] | ||
pub struct TriePrefetchStats { | ||
branches_prefetched: u64, | ||
leaves_prefetched: u64, | ||
} | ||
|
||
impl TriePrefetchStats { | ||
/// The number of added branch nodes for which we prefetched. | ||
pub const fn branches_prefetched(&self) -> u64 { | ||
self.branches_prefetched | ||
} | ||
|
||
/// The number of added leaf nodes for which we prefetched. | ||
pub const fn leaves_prefetched(&self) -> u64 { | ||
self.leaves_prefetched | ||
} | ||
} | ||
|
||
/// Trie metrics tracker. | ||
#[derive(Default, Debug, Clone, Copy)] | ||
pub struct TriePrefetchTracker { | ||
branches_prefetched: u64, | ||
leaves_prefetched: u64, | ||
} | ||
|
||
impl TriePrefetchTracker { | ||
/// Increment the number of branches prefetched. | ||
pub fn inc_branches(&mut self, num: u64) { | ||
self.branches_prefetched += num; | ||
} | ||
|
||
/// Increment the number of leaves prefetched. | ||
pub fn inc_leaves(&mut self, num: u64) { | ||
self.leaves_prefetched += num; | ||
} | ||
|
||
/// Called when prefetch is finished to return trie prefetch statistics. | ||
pub const fn finish(self) -> TriePrefetchStats { | ||
TriePrefetchStats { | ||
branches_prefetched: self.branches_prefetched, | ||
leaves_prefetched: self.leaves_prefetched, | ||
} | ||
} | ||
} |