From: akr@...
Date: 2020-04-10T14:48:03+00:00
Subject: [ruby-core:97804] [Ruby master Bug#16740] Deprecating and removing the broken Process.clock_getres

Issue #16740 has been updated by akr (Akira Tanaka).


Eregon (Benoit Daloze) wrote in #note-3:
> OK. I'll improve the documentation to mention it's basically unreliable or broken on most operating systems.

When describing such broken behavior, please describe
(1) OS version and (2) actual behavior
to confirm the behavior in future.


----------------------------------------
Bug #16740: Deprecating and removing the broken Process.clock_getres
https://bugs.ruby-lang.org/issues/16740#change-85022

* 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>