Skip to content

Commit

Permalink
Debug scheduler drift
Browse files Browse the repository at this point in the history
  • Loading branch information
Smjert committed Jul 3, 2024
1 parent d47fc84 commit af4a64c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions osquery/dispatcher/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,17 @@ void SchedulerRunner::calculateTimeDriftAndMaybePause(
if (loop_step_duration + time_drift_ < interval_) {
pause(interval_ - loop_step_duration - time_drift_);
time_drift_ = std::chrono::milliseconds::zero();
std::cout << "SCHEDULE SLEEP" << std::endl;
} else {
time_drift_ += loop_step_duration - interval_;
if (time_drift_ > max_time_drift_) {
// giving up
time_drift_ = std::chrono::milliseconds::zero();
std::cout << "TOO MUCH DRIFT" << std::endl;
}
}

std::cout << "CURRENT DRIFT: " << time_drift_.count() << std::endl;
}

void SchedulerRunner::maybeRunDecorators(uint64_t time_step) {
Expand Down Expand Up @@ -325,8 +329,8 @@ void SchedulerRunner::start() {
}
}

std::chrono::milliseconds SchedulerRunner::getCurrentTimeDrift() const
noexcept {
std::chrono::milliseconds SchedulerRunner::getCurrentTimeDrift()
const noexcept {
return time_drift_;
}

Expand Down

0 comments on commit af4a64c

Please sign in to comment.