Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A backend for Ruby >= 2.1 using Process.clock_gettime #72

Closed
eregon opened this issue Feb 7, 2019 · 9 comments
Closed

A backend for Ruby >= 2.1 using Process.clock_gettime #72

eregon opened this issue Feb 7, 2019 · 9 comments
Milestone

Comments

@eregon
Copy link
Contributor

eregon commented Feb 7, 2019

Since Ruby 2.1, there is Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond).
This uses the appropriate syscall based on the platform.

If hitimes would use this on Ruby >= 2.1, I think no C or JRuby extension would be needed, and there would be no need to access macOS frameworks.

The issue was initially reported in oracle/truffleruby#1436, where TruffleRuby does not support -framework yet. It probably could, but it seems better to use a core method when available rather than re-implementing it with a C extension.

Do you want to keep supporting Ruby 2.0?
If not, then the whole C/JRuby extensions could likely go away altogether, but that would also mean every gem depending on hitimes must drop Ruby <= 2.0 support too.

@copiousfreetime What do you think?

@copiousfreetime
Copy link
Owner

copiousfreetime commented Feb 7, 2019

@eregon I had this as a todo for a long time (see #22) and after digging into it last year it looked ruby natively doesn't support the nanosecond resolution on at least OSX even though it could.

And after reviewing the code I was looking at last summer...It appears I was looking at the wrong bits of the ruby source code. I did a better review just now - and it looks like that ruby's Process.clock_gettime will work. So - should be doable to make hitimes pure ruby. i'd also end up removing the stats calculations - as those are in C also.

I'll play around with some things and see what comes out. In any case - this would probably end up with a major version bump just to cover the < Ruby 2.1 deprecation.

@eregon
Copy link
Contributor Author

eregon commented Feb 8, 2019

Sounds good. I searched for Process.clock_gettime before filing an issue but found nothing.

FWIW, I found out recent macOS also supports clock_gettime(2) directly.

One way to already use Process.clock_gettime in hitimes 1.x would be to keep the extensions as fallback for Ruby < 2.1 for a single 1.x release. And then a 2.0 release would then drop Ruby < 2.1 compatibility. The advantage is every dependency using hitimes 1.x on Ruby >= 2.1 would then use core Ruby features.

@ioquatix
Copy link

ioquatix commented Feb 8, 2019

Just FYI, I moved to using Process.clock_gettime in async and timers so that is no longer a major dependency (of course old versions still are). It was a point release for timers. So I believe most users can update.

So, @copiousfreetime your offer to update the gem is awesome, but if you have other things to spend your time on that are more valuable to you, it's no longer a dependency of timers.

Thanks so much for this gem and all your work.

@copiousfreetime
Copy link
Owner

copiousfreetime commented Feb 24, 2019

Almost completed extension removal over in #73

@eregon
Copy link
Contributor Author

eregon commented Feb 24, 2019

This looks great!

@copiousfreetime
Copy link
Owner

@eregon well - my pure ruby version also doesn't work on truffleruby 😂 - I've sent a pull request over to truffle ruby - oracle/truffleruby#1594 - not sure if that's the right way to go or not - all feedback welcome.

@eregon
Copy link
Contributor Author

eregon commented Feb 25, 2019

@copiousfreetime Great 😃

I also commented on the PR #73. Did Hitimes provide clock resolution before?

@copiousfreetime
Copy link
Owner

Version 2.0.0 pushed with no C extension

@eregon
Copy link
Contributor Author

eregon commented Sep 23, 2019

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants