-
Notifications
You must be signed in to change notification settings - Fork 89
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
Linux kernel ticks assumption is error prone #122
Comments
IIUC, looking at 2.6.23 (the earliest kernel supported by Go) the two architectures that do not use 100 HZ are alpha and ia64. And neither of those are supported by Go. But I agree it would be more correct to use the There's some good discussion of this in containerd/cgroups#12. |
I was curious what go-sysconf did for this since it claims to not use cgo. const (
// CLK_TCK is a constant on Linux for all architectures except alpha and ia64.
// See e.g.
// https://git.musl-libc.org/cgit/musl/tree/src/conf/sysconf.c#n30
// https://github.com/containerd/cgroups/pull/12
// https://lore.kernel.org/lkml/[email protected]/
_SYSTEM_CLK_TCK = 100
) |
@andrewkroh - thank you for the quick response.
Seems they are both obsolete so it makes this issue less important. |
Problem
The value of clock ticks (
_SC_CLK_TCK
) is hard coded and might varies across kernel versions and hardware platforms, it would probably be best if you could read this value dynamically.go-sysinfo/providers/linux/process_linux.go
Line 33 in bd131ab
There is an assumption here for certain conditions that might not be respected between different deployments and versions.
please read the wiki article about Kernel Timer Systems:
Proposed solution
Make a sys call to retrieve the actual
_SC_CLK_TCK
and use it for process time calculations, the same has been done for Darwin:go-sysinfo/providers/darwin/syscall_darwin.go
Lines 191 to 194 in f2015f1
The text was updated successfully, but these errors were encountered: