oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.02k stars 185 forks source link

Process CLOCK_MONOTONIC_RAW_APPROX, CLOCK_UPTIME_RAW, and CLOCK_UPTIME_RAW_APPROX constants are not supported #1480

Closed deepj closed 2 years ago

deepj commented 5 years ago

This is specific for macOS and it was introduced in Ruby 2.4. See https://github.com/ruby/ruby/blob/v2_4_0/NEWS

To reproduce (only on macOS, I guess):

Process::CLOCK_MONOTONIC_RAW_APPROX

Error:

NameError: uninitialized constant Process::CLOCK_MONOTONIC_RAW_APPROX
Did you mean?  Process::CLOCK_MONOTONIC_RAW_ID
    from (irb):2:in `const_missing'
    from (irb):2
    from ~/.rubies/truffleruby-1.0.0-rc9/bin/irb:29:in `<main>'
eregon commented 5 years ago

I'm curious, which library uses this constant?

deepj commented 5 years ago

No one in my case, I just saw this in Ruby 2.4 NEWS. So I just was curious to try it 😇

chrisseaton commented 5 years ago

For Linux we need to implement

chrisseaton commented 5 years ago

Fix on the way.

chrisseaton commented 5 years ago

Sorry this was fixed ages ago, forgot to close it.

nickh-stripe commented 2 years ago

This doesn't seem fixed or fixed still? On latest truffleruby:

Process::CLOCK_BOOTTIME
(irb):4:in `const_missing': uninitialized constant Process::CLOCK_BOOTTIME (NameError)
Did you mean?  Process::CLOCK_REALTIME
eregon commented 2 years ago

It was fixed but regressed, unfortunately the test guard was written incorrectly and so missed the regression (I'll fix that). The regression is 37b70d4120f732598708e01195f644c833e2baba. So the fundamental issue is our CI platform (Oracle Linux 7) doesn't have these clocks, and so we can't reliably expose the clock value since the clock might or not exist depending on the Linux version.

@nickh-stripe Do you need CLOCK_BOOTTIME for something specific? Isn't CLOCK_MONOTONIC enough?

eregon commented 2 years ago

I've got a fix. The trade-off is it will also define these clocks as Process constants on older Linux, and using them with clock_gettime raises EINVAL.

nickh-stripe commented 2 years ago

Thanks, just some existing code was using it, I don't know enough about why to say whether it could be substituted, just thought reporting it for a easy fix might be beneficial to all 👍 thanks for the quick turnaround.