-
Notifications
You must be signed in to change notification settings - Fork 236
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
Simplify ticks, as the value is a constant #12
Conversation
Hmm, looks like a Prom API change has broken the CI... |
Can you rebase this one so it picks up your fix? |
Wouldn't this cause portable issue? If it's about removing cgo dependency, maybe we can use |
I've never need it not 100 but it is possible. @justincormack should we add the cgo build tag for this file and then have a hard coded 100 in a !cgo file? |
See for example in the Musl libc source code https://git.musl-libc.org/cgit/musl/tree/src/conf/sysconf.c#n29 This removes another cgo dependency in `containerd`. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2ed7adc
to
ba3e9ce
Compare
Codecov Report
@@ Coverage Diff @@
## master #12 +/- ##
=======================================
Coverage 36.69% 36.69%
=======================================
Files 21 21
Lines 1398 1398
=======================================
Hits 513 513
Misses 786 786
Partials 99 99
Continue to review full report at Codecov.
|
The value is a constant in Linux, there is no point in "dynamically" looking it up. This is cgroups code so only runs on Linux. To quote Linus: https://groups.google.com/forum/#!msg/fa.linux.kernel/JndVy0RgHHI/Nu7nkRfZ-c0J
(tick rate internally in the kernel can now be variable, so this API would be useless anyway). This is just an artefact of the ABI. It does not vary by architecture, as I said above it is hard coded in libc too. |
Its still a changeable constant though ? With |
Also for some arch like alpha or ia64, this is not 100 iirc. Though we probably not care about them now with this library. |
No, it is a constant constant. It is the same on every architecture. The ELF aux value is only used on Glibc with dynamically linked programs, Musl libc always sets it to 100, and as you can see in |
LGTM By "changeable constant" i meant someone can go in and change the value and recompile 😄 , then the program compiled on another kernel will have incorrect value. Not sure if we care though, i think this change is really ok in practice. |
LGTM |
CLK_TCK is always 100 on Linux. For example, musl hard-codes this https://git.musl-libc.org/cgit/musl/tree/src/conf/sysconf.c#n30 and glibc looks it up from the ELF auxv, but the kernel sets it to 100 on all architectures (except alpha and ia64, both of which are obsolete and not supported by Go). Also see containerd/cgroups#12
See for example in the Musl libc source code https://git.musl-libc.org/cgit/musl/tree/src/conf/sysconf.c#n29
This removes another cgo dependency in
containerd
.Signed-off-by: Justin Cormack justin.cormack@docker.com