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

timer: All configuration of granularity #367

Closed
sdroege opened this issue May 15, 2018 · 4 comments
Closed

timer: All configuration of granularity #367

sdroege opened this issue May 15, 2018 · 4 comments

Comments

@sdroege
Copy link
Contributor

sdroege commented May 15, 2018

Currently the timer granularity is always 1ms. It would be nice to be able to configure this, to be able to have a higher granularity < 1ms, or what is needed in my case, a lower one (e.g. 20ms).

My use-case is to batch process timers: everything that is to be emitted in those e.g. 20ms should be handled at once, instead of waking up the thread many times during those 20ms and cause more context switches, CPU usage and power consumption.

Alternatively, some API to schedule timers with a specific granularity (like e.g. in GLib g_timeout_add_seconds) would be nice. So that e.g. all timers that are scheduled with 20ms granularity will be triggered at the same time, all timers with 1s granularity at the same time, etc.

@carllerche
Copy link
Member

One option would be to only set timeouts at 20ms granularity. In that case, the thread shouldn't have to wake up? Since everything is deadline based, it should be possible to ensure that timeouts get set in 20ms increments. Does something like this work?

@sdroege
Copy link
Contributor Author

sdroege commented May 30, 2018

Would that ensure that timers are always at 20ms boundaries, i.e. the absolute difference between any two timers' "trigger times" is always an integer multiple of 20ms? Then that would work, yes

@carllerche
Copy link
Member

Closing due to inactivity.

@jonhoo
Copy link
Sponsor Contributor

jonhoo commented Jun 25, 2019

See also tokio-os-timer for finer-grained timers.

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