Skip to content

When running on AMD calibrate TSC using timer#45

Merged
vadimskipin merged 1 commit into
mainfrom
vskipin/fix-tsc-calibration
May 15, 2026
Merged

When running on AMD calibrate TSC using timer#45
vadimskipin merged 1 commit into
mainfrom
vskipin/fix-tsc-calibration

Conversation

@vadimskipin
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a runtime TSC frequency calibration fallback for x86_64 platforms where CPUID does not expose the TSC frequency (notably AMD CPUs and some older Intel parts). When getTscFrequencyCpuid() returns 0, Tsc::initialize() now measures TSC ticks against CLOCK_MONOTONIC over a 50 ms window using clock_nanosleep.

Changes:

  • Adds getTscFrequencyCalibrated() helper using clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, ...) to measure cycles over 50 ms.
  • Wires the calibration as a fallback in Tsc::initialize() when CPUID-based detection yields 0.
  • Adds includes for <silk/util/platform.h> (for getTimeNanoseconds) and <cerrno> (for EINTR).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@vadimskipin vadimskipin merged commit 4e94ba4 into main May 15, 2026
22 checks passed
@vadimskipin vadimskipin deleted the vskipin/fix-tsc-calibration branch May 15, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants