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

Slowing down and speeding up an interval_timer #3244

Closed
xaguilar opened this issue Mar 19, 2018 · 5 comments
Closed

Slowing down and speeding up an interval_timer #3244

xaguilar opened this issue Mar 19, 2018 · 5 comments

Comments

@xaguilar
Copy link
Contributor

Hi,

I was checking the code in hpx::util::interval_timer to slow down and speed up a timer and I'm a bit confused.

In the function interval_timer::slow_down for example, the new value is chosen using std::min between the new value and a variation of the old one. For me, slowing down a timer would imply to increase the timer interval, and thus, using a greater value. For example going from 1 microsec to 4 microsecs for the timer. However, using the std::min in slow_down makes the function to never select the new greater value passed to the function (4 microsecs in my previous example). The same happens with interval_timer::speed_up, it uses std::max, thereby never choosing the new smaller time interval to speed up the timer. I'm a bit confused in here, am I getting it wrong or is this a bug?

Thanks a lot!

@hkaiser
Copy link
Member

hkaiser commented Mar 19, 2018

It's mostly a matter of how you interpret slow-down and speed-up. The current slow-down function makes the interval max 10% larger. The user is responsible for passing in a value for the timer that doesn't reduce the interval.

Granted, these are unusual semantics (mostly born out of historical necessity) and the functionality is not needed in HPX, currently. I'd suggest we completely remove it.

Reversing the use of std::min and std::max in the existing code wouldn't make things less unexpected, btw. No matter what values a user supplies, the values always would change by at least 10%, also there wouldn't be any protection from actually speeding up a timer using the slow-down function (or v.v.).

@xaguilar
Copy link
Contributor Author

Thanks a lot for your reply Hartmut! So what would you recommend to change the frequency of an interval_timer then? Destroy the old one and create a new one?

@hkaiser
Copy link
Member

hkaiser commented Mar 19, 2018

@xaguilar Ahh, so you need this functionality? In this case I'd suggest properly fixing the semantics and implementation of those functions. Would you mind working on this?

@xaguilar
Copy link
Contributor Author

@hkaiser Sure, I can have a look at it.

@msimberg msimberg removed this from the 1.1.0 milestone Mar 22, 2018
@hkaiser
Copy link
Member

hkaiser commented Jun 15, 2018

This was fixed by merging #3251

@hkaiser hkaiser closed this as completed Jun 15, 2018
@msimberg msimberg added this to the 1.2.0 milestone Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants