-
Notifications
You must be signed in to change notification settings - Fork 569
Timestamp generator #681
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
Timestamp generator #681
Conversation
|
LGTM Jim. Can you give a try to our benchmark scripts to see how the lock in that generator affects the performance? |
cassandra/timestamps.py
Outdated
|
|
||
| def _maybe_warn(self, now): | ||
| # should be called from inside the self.lock. | ||
| diff = now - self._last_warn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line should be:
diff = self.last - now
as this value may be logged below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good catch!
cassandra/timestamps.py
Outdated
| since_last_warn = now - self._last_warn | ||
|
|
||
| warn = (self.warn_on_drift and | ||
| (diff >= self.warning_threshold) and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comparison would be:
self.last + 1 - now >= self.warning_threshold
as the comparison should be done with the value that is going to be returned right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be since_last_warn >= self.warning_threshold -- we're trying to avoid flooding logs, so we care about how long it's been since the last warning was issued. Sound right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is checked in the next line right?
since_last_warn >= self.warning_interval
This lines checks the returned timestamp drifts more than warning_threshold seconds into the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep -- sorry, I should've spent more time reading for context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry again for my confusion. To address your original concern: I think either behavior (comparing to self.last - now or to self.last + 1 - now) is reasonable. I had a look at at the Java implementation:
It looks like the behavior there is the same as that in the PR -- so self.last - now. Personally, I don't see a good reason to make the implementation work differently than the Java driver's. Do you object to it strongly enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, self.last - now should be fine
f07576c to
b6f4a9b
Compare
|
I've changed some things about the seconds / microseconds inside the class |
da4aed3 to
2b4e111
Compare
|
@bjmb I've added a small fix that tears down the patched |
|
@mambocab great! Sure, go ahead with the squash and merge. |
5836990 to
0c25970
Compare
Addresses PYTHON-676. The history isn't great, but I plan to squash before/on merge if there are no objections.
Unit and integration tests pass locally on py2.7. I have not tested this over actual timestamp discontinuities.