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

common: use mono clock for HeartbeatMap #17213

Closed
wants to merge 1 commit into from

Conversation

XinzeChi
Copy link
Contributor

Signed-off-by: Xinze Chi xinze@xsky.com

@xiexingguo
Copy link
Member

s/heaerbeatmap/HeartbeatMap/

@XinzeChi XinzeChi changed the title common: use mono clock for heaerbeatmap common: use mono clock for HeartbeatMap Aug 24, 2017
@@ -79,12 +80,12 @@ class HeartbeatMap {
private:
CephContext *m_cct;
RWLock m_rwlock;
time_t m_inject_unhealthy_until;
unsigned m_inject_unhealthy_until;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is a time_point instead wouldn't that avoid most of the casts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, would be easier if this is a time_point.

std::list<heartbeat_handle_d*> m_workers;
std::atomic<unsigned> m_unhealthy_workers = { 0 };
std::atomic<unsigned> m_total_workers = { 0 };

bool _check(const heartbeat_handle_d *h, const char *who, time_t now);
bool _check(const heartbeat_handle_d *h, const char *who, ceph::coarse_mono_clock::time_point& now);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass by const ceph::coarse_mono_clock::time_point&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with kefu.


was = h->timeout;
if (was && was < now) {
if (was && was < std::chrono::time_point_cast<std::chrono::seconds>(now).time_since_epoch().count()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to use typdef for 'std::chrono::time_point_caststd::chrono::seconds' instead repeating again & again

@tchaikov
Copy link
Contributor

@XinzeChi ping.

@XinzeChi
Copy link
Contributor Author

@tchaikov pong

@@ -79,12 +80,12 @@ class HeartbeatMap {
private:
CephContext *m_cct;
RWLock m_rwlock;
time_t m_inject_unhealthy_until;
unsigned m_inject_unhealthy_until;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, would be easier if this is a time_point.

_check(h, "reset_timeout", now);

h->timeout = now + grace;
h->timeout = tp_to_seconds(now) + grace;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to use std::atomic<ceph::coarse_mono_clock> for heartbeat_handle_d::timeout and heartbeat_handle_d::suicide_timeout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Xinze Chi <xinze@xsky.com>
@tchaikov
Copy link
Contributor

tchaikov commented Sep 20, 2017

closing in favor of #17827

@tchaikov tchaikov closed this Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants