Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the ClocksPerSec scaling factor on Darwin #846

Merged
merged 2 commits into from
Mar 7, 2018
Merged

Correct the ClocksPerSec scaling factor on Darwin #846

merged 2 commits into from
Mar 7, 2018

Conversation

colmbuckley
Copy link
Contributor

Change the definition of ClocksPerSec to read from limits.h

Per #845, CPU counters are scaled by an incorrect factor (128 was assumed, which is the FreeBSD default [?]). Correct value on Darwin is given by the C macro CLK_TCK in limits.h

Change the definition of ClocksPerSec to read from limits.h
@@ -45,7 +46,7 @@ import (
import "C"

// ClocksPerSec default value. from time.h
const ClocksPerSec = float64(128)
const ClocksPerSec = C.CLK_TCK
Copy link
Member

Choose a reason for hiding this comment

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

We want to keep the float64() cast to avoid integer math.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, ack.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

LGTM

@SuperQ
Copy link
Member

SuperQ commented Mar 7, 2018

The circleci build failure is due to Go 1.10 not being in the Circle 1.0 machine. Plus it doesn't test Darwin anyway. I tested this patch locally, looks good.

@SuperQ SuperQ merged commit 098f975 into prometheus:master Mar 7, 2018
@colmbuckley colmbuckley deleted the patch-1 branch March 7, 2018 11:00
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
* Update cpu_darwin.go

Change the definition of ClocksPerSec to read from limits.h

* Update cpu_darwin.go
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.

3 participants