timeout icon indicating copy to clipboard operation
timeout copied to clipboard

TIMEOUT_mHZ and friends seem wrong

Open nmathewson opened this issue 9 years ago • 1 comments

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 avatar Feb 19 '16 23:02 nmathewson

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 :(

wahern avatar Mar 02 '16 20:03 wahern