From: eregontp@... Date: 2020-04-10T21:47:58+00:00 Subject: [ruby-core:97818] [Ruby master Bug#16740] Deprecating and removing the broken Process.clock_getres Issue #16740 has been updated by Eregon (Benoit Daloze). akr (Akira Tanaka) wrote in #note-8: > It doesn't describe OS version and actual problem of OS behavior. If you look at the "blame" you can easily find CI logs, including OS versions and which clocks failed. Blame: https://github.com/ruby/spec/blame/ec844797a51a017ebc93af833e421362b4b24a17/core/process/fixtures/clocks.rb#L19-L59 For instance: https://github.com/ruby/spec/commit/730d967e06b0f3512e37c2105f1c44c717be674c https://github.com/ruby/spec/commit/1090192fd712ab5f6e30c0535bac3c52a2af47e5 https://github.com/ruby/spec/commit/c3c89c580a2c4c6d12e055ef21da5ef5c8f6e81e ---------------------------------------- Bug #16740: Deprecating and removing the broken Process.clock_getres https://bugs.ruby-lang.org/issues/16740#change-85036 * Author: Eregon (Benoit Daloze) * Status: Rejected * Priority: Normal * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- clock_getres(2) is incorrect (doesn't match the actual resolution for many clocks), buggy (e.g. can return negative values) on almost all platforms and for almost all clock_id. This is an observation based running specs for it: https://github.com/ruby/spec/blob/ec844797a51a017ebc93af833e421362b4b24a17/core/process/clock_getres_spec.rb https://github.com/ruby/spec/blob/ec844797a51a017ebc93af833e421362b4b24a17/core/process/fixtures/clocks.rb#L19-L59 See how many exceptions there are. And that's not all, even CLOCK_MONOTONIC on Linux is buggy: https://github.com/ruby/actions/runs/395166997#step:16:155 My conclusion is this API is unusable for any purpose. If people want to know the resolution for clock_gettime(), they need to call it repetitively and see how precise it is. I will remove the "matches the clock in practice" specs for clock_getres() as I'm tired to maintain them. But I think we should remove this impossible-to-use correctly API, because it's fundamentally broken on all platforms. So I propose to deprecate and remove this API, because I believe it harms more than it helps for Rubyists. Kernel hackers which want to use that function can always call it via Fiddle/FFI, but it shouldn't be a proper Ruby API since it's so broken at the OS level. -- https://bugs.ruby-lang.org/ Unsubscribe: