From: eregontp@... Date: 2020-04-10T22:09:19+00:00 Subject: [ruby-core:97819] [Ruby master Bug#16740] Deprecating and removing the broken Process.clock_getres Issue #16740 has been updated by Eregon (Benoit Daloze). mame (Yusuke Endoh) wrote in #note-9: > But some people said, it might be only guaranteed that the number returned by `clock_gettime` is a multiple of the resolution. Sometimes it returns a resolution less than precise than the clock, but sometimes more precise than the clock, i.e., it's inaccurate both ways. I don't think it's an issue of the spec, manual testing also confirms it's inaccurate: https://github.com/ruby/spec/commit/ec48b92efe3f1d234110eefcea7140896219734d#diff-8906d6a3637b6976b884ac506096afc5 And sometimes it's plain buggy and I doubt this can be seen any other way when clock_getres() returns a negative value: https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos6/ruby-trunk/log/20190428T093004Z.fail.html.gz I don't have time to report these bugs to all operations systems. I've spent hours trying to fix that spec and saw 5+ operating systems fail on in total 10+ clocks, that's all the proof I need to say this is completely broken and unusable. Feel free to tweak the wording in RDoc if you think "operating system bugs" is too strong but I think it's accurate. I mean it mostly as "not Ruby's bug, but a bug below and OS are inaccurate differently for `clock_getres()` so it seems most likely a bug of the OS". ---------------------------------------- Bug #16740: Deprecating and removing the broken Process.clock_getres https://bugs.ruby-lang.org/issues/16740#change-85037 * 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: