From c28258675313f27b4ee8820d76c147418c6b302d Mon Sep 17 00:00:00 2001 From: sakridge Date: Tue, 5 Jan 2021 19:25:44 -0800 Subject: [PATCH] Add fixed tick rate adjustment (#14447) --- core/src/poh_service.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/poh_service.rs b/core/src/poh_service.rs index c104a4c74d..fc97b527ae 100644 --- a/core/src/poh_service.rs +++ b/core/src/poh_service.rs @@ -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>, @@ -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, ); }