Add fixed tick rate adjustment (#14447) (#14458)

(cherry picked from commit c282586753)

Co-authored-by: sakridge <sakridge@gmail.com>
This commit is contained in:
mergify[bot]
2021-01-06 04:47:13 +00:00
committed by GitHub
parent 599f5a16b2
commit 50ebc3f4d8

View File

@ -21,6 +21,8 @@ pub const NUM_HASHES_PER_BATCH: u64 = 1;
pub const DEFAULT_PINNED_CPU_CORE: usize = 0;
const TARGET_SLOT_ADJUSTMENT_NS: u64 = 50_000_000;
impl PohService {
pub fn new(
poh_recorder: Arc<Mutex<PohRecorder>>,
@ -52,10 +54,17 @@ impl PohService {
if let Some(cores) = core_affinity::get_core_ids() {
core_affinity::set_for_current(cores[pinned_cpu_core]);
}
// Account for some extra time outside of PoH generation to account
// for processing time outside PoH.
let adjustment_per_tick = if ticks_per_slot > 0 {
TARGET_SLOT_ADJUSTMENT_NS / ticks_per_slot
} else {
0
};
Self::tick_producer(
poh_recorder,
&poh_exit_,
poh_config.target_tick_duration.as_nanos() as u64,
poh_config.target_tick_duration.as_nanos() as u64 - adjustment_per_tick,
ticks_per_slot,
);
}