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

TIMEOUT_mHZ and friends seem wrong #7

Open
nmathewson opened this issue Feb 19, 2016 · 1 comment
Open

TIMEOUT_mHZ and friends seem wrong #7

nmathewson opened this issue Feb 19, 2016 · 1 comment

Comments

@nmathewson
Copy link

The 'hz' argument is supposed to count frequency. But TIMEOUT_mHZ is not a millihertz; it is a kHz, which corresponds to a frequency of a millisecond. Similarly, TIMEOUT_uHZ is really a MHz, which corresponds to a microsecond; and TIMEOUT_nHZ is really a GHz, corresponding to a nanosecond.

I'm not sure whether it's worthwhile to rename these to the proper SI values, or just to add a comment.

nmathewson added a commit to nmathewson/timeout that referenced this issue Feb 20, 2016
These currently cover most reachable lines and branches, except the
case where malloc fails in timeouts_open(), the if() branch in
timeouts_readd() (see issue wahern#7) , and some failure cases in
timeouts_check().
@wahern
Copy link
Owner

wahern commented Mar 2, 2016

I'm fine with adding new names and deprecating the old ones.

IIRC, at the time I was thinking in terms of an abstract clock. For a wheel initialized with TIMEOUT_mHZ you'd need to call timeouts_step(1) one-thousand times in order to progress the clock by the same period compared to a wheel with a stepping of 1 HZ. So each step of the former is literally 1/1000th of the latter. But in neither case was I thinking in terms of elapsed wall-clock seconds, but more of the abstract progression of the stepping. If you're thinking in terms of the number of cycles relative to the wall clock (which in retrospect is what smart people would do with HZ units), then it definitely make more sense to use kilohertz, etc.

I was unsure whether to use the term hertz at all because I realize it didn't quite fit. I wanted to use something like jiffy, and that's what I was using for awhile. But for whatever reason it seemed less intuitive for a naming convention intended to make it clearer about how to to integrate with use of struct timeval (microseconds) or struct timespec (nanoseconds).

I'll concede I made the wrong choice, and probably just ended up confusing myself and others. Sometimes you forget the path you followed to arrive at a certain juncture, and are too tired to think it through again :(

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

2 participants