Project

General

Profile

Actions

Bug #16740

closed

Deprecating and removing the broken Process.clock_getres

Added by Eregon (Benoit Daloze) about 4 years ago. Updated almost 4 years ago.

Status:
Rejected
Target version:
-
[ruby-core:97609]

Description

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.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #8809: Process.clock_getresClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0