FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::TscCalibrator Class Reference

Long-baseline TSC calibration for the calibrator (control) thread. More...

#include <fastmm/core/time.hpp>

Public Member Functions

 TscCalibrator (ClockReadings readings=system_clock_readings()) noexcept
 
TscCalibration start (Duration window=milliseconds(50)) noexcept
 
TscRecalibration update () noexcept
 
const TscCalibration & current () const noexcept
 

Static Public Attributes

static constexpr Duration kMinBaseline = milliseconds(500)
 

Detailed Description

Long-baseline TSC calibration for the calibrator (control) thread.

start() measures an initial rate over a short spin. update() takes only a fresh anchor and derives the rate from the whole interval since the previous anchor, against CLOCK_MONOTONIC_RAW:

  • anchor jitter (clock_gettime latency spikes of tens of microseconds on a busy or virtualised host) costs a few ppm over a 10 s baseline instead of thousands of ppm over a 50 ms window, which used to drift the mapping by milliseconds between recalibrations and force steps;
  • NTP slews and host wall-clock steps (WSL2 resynchronising with Windows) cannot distort the rate. A wall-clock step is reported separately in host_step_ns; the published anchor still follows CLOCK_REALTIME, so TscClock steps with the host when it has to.

Constructor & Destructor Documentation

◆ TscCalibrator()

fastmm::TscCalibrator::TscCalibrator ( ClockReadings  readings = system_clock_readings())
inlineexplicitnoexcept

Member Function Documentation

◆ start()

TscCalibration fastmm::TscCalibrator::start ( Duration  window = milliseconds(50))
noexcept

◆ update()

TscRecalibration fastmm::TscCalibrator::update ( )
noexcept

◆ current()

const TscCalibration & fastmm::TscCalibrator::current ( ) const
inlinenoexcept

Member Data Documentation

◆ kMinBaseline

constexpr Duration fastmm::TscCalibrator::kMinBaseline = milliseconds(500)
staticconstexpr