From: mame@... Date: 2020-04-11T01:51:56+00:00 Subject: [ruby-core:97821] [Ruby master Bug#16740] Deprecating and removing the broken Process.clock_getres Issue #16740 has been updated by mame (Yusuke Endoh). Eregon (Benoit Daloze) wrote in #note-11: > 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". Personally, I like to write nothing about the accuracy if we cannot be responsible. As @akr said, OS names and behaviors should be elaborated in the note so that we will be able to determine if the underlying API is fixed and to remove the note in future. We cannot do so if only "inaccurate on most platform" is written. If no document is written at all, we don't have to do nothing. We can consider adding such a note if many people face the accuracy issue in practice and report to Ruby. ---------------------------------------- Bug #16740: Deprecating and removing the broken Process.clock_getres https://bugs.ruby-lang.org/issues/16740#change-85043 * 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: