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

High-precision timers #970

Closed
polachok opened this issue Mar 11, 2019 · 8 comments
Closed

High-precision timers #970

polachok opened this issue Mar 11, 2019 · 8 comments

Comments

@polachok
Copy link
Contributor

Version

0.1.16

Platform

Linux e8ab1d1f59b1 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Subcrates

tokio-timer

Description

tokio-timer supports delays with 1ms resolution, while my use case requires higher resolution timers.
On Linux, timerfd provides access to sub-millisecond timers as file descriptors. I implemented a simple periodic timer in tokio-timerfd, which works fine, but I would also like to have APIs like DelayQueue. I'm asking for advice on how to best proceed with this. I'd like to avoid duplicating tokio-timer code in my crate, but it seems like there's no way to plug in my own timer implementation.

@carllerche
Copy link
Member

Good question. Do you have any thoughts on how to proceed?

@polachok
Copy link
Contributor Author

I played with one approach in this PR: https://github.com/polachok/tokio/pull/1/files.
It adds TimerImpl trait which can be implemented by timers and injected into runtime.

@polachok
Copy link
Contributor Author

@carllerche any comments?

@tobz
Copy link
Member

tobz commented Mar 19, 2019

@polachok Is there anyway you could submit your PR on this repo?

It'll give others a better chance to review and contribute.

@polachok
Copy link
Contributor Author

@tobz it's more a proof-of-concept than a proper PR, but if you think it's approriate, I will

@DoumanAsh
Copy link
Contributor

I've been playing around with generic timer implementation here, if you're interested

But it targets std's futures, so there is only romio integration for timerfd and kqueue.
Not sure how easy it would be integrate with tokio as it needs Waker

@carllerche
Copy link
Member

It would probably be fine to provide a highres-timer option in Tokio... or update tokio_timer::Delay to have an option to pick high res.

@carllerche
Copy link
Member

That said, I'm going to close due to inactivity.

Any proposal that would be considered for inclusion in Tokio would need to:

  • Support linux, *bsd, and windows platforms.
  • Include an API proposal
  • Include an argument for why it is useful to have a timer with greater than a 1ms resolution in an asynchronous context.

I looked quickly at windows and I do not see an obvious option there. However, if someone wants to take a stab at this, I would suggest opening a new issue w/ the proposal and cross reference this issue.

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

4 participants