From mboxrd@z Thu Jan 1 00:00:00 1970 From: Erwan Velu Subject: Re: About ceph_clock_now() Date: Tue, 19 Jan 2016 11:17:51 -0500 (EST) Message-ID: <1365711662.13730117.1453220271917.JavaMail.zimbra@redhat.com> References: <177186823.10053087.1452614184109.JavaMail.zimbra@redhat.com> <892700092.10054838.1452614393452.JavaMail.zimbra@redhat.com> <20160112173248.GA8218@ultraspiritum.redhat.com> <964746730.10566211.1452681675142.JavaMail.zimbra@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from mx5-phx2.redhat.com ([209.132.183.37]:50885 "EHLO mx5-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932168AbcASQRx convert rfc822-to-8bit (ORCPT ); Tue, 19 Jan 2016 11:17:53 -0500 In-Reply-To: Sender: ceph-devel-owner@vger.kernel.org List-ID: To: Sage Weil Cc: "Adam C. Emerson" , The Sacred Order of the Squid Cybernetic Before propagating the change to more code base and offer a PR with tha= t, what do you think of this style ? Is it aligned with the best-pratices of the project ? https://gist.github.com/ErwanAliasr1/f74f7f046e9300ac2c30 Thanks, ----- Mail original ----- De: "Sage Weil" =C3=80: "Erwan Velu" Cc: "Adam C. Emerson" , "The Sacred Order of the S= quid Cybernetic" Envoy=C3=A9: Mercredi 13 Janvier 2016 14:48:00 Objet: Re: About ceph_clock_now() On Wed, 13 Jan 2016, Erwan Velu wrote: > >One concern with monotonic clocks, even for elapsed time, is that th= eir epoch is > >unspecified. You cannot send a monotonic time over the network to an= other > >machine nor can you save it to a file and re-read it later. Anything= to be > >serialized must be a real time. >=20 > While speaking about ceph_clock_now(), I was more likely targeting lo= ts of local code like > start =3D ceph_clock_now(); > ... do_stuff ... > elapse_time =3D ceph_clock_now() - start >=20 >=20 > I'm thinking of code like this in void OSD::tick_without_osd_lock(): > Starting at https://github.com/ceph/ceph/blob/master/src/osd/OSD.cc#L= 4009. >=20 > This code is trying to estimate if a mon is still alive by computing = a difference of system time by > doing a "if (now - last_pg_stats_sent > max) {" where now & last_pg_= stats_sent are the output of "ceph_clock_now()" >=20 > As ceph_clock_now() is using CLOCK_REALTIME, we could have cases wher= e a simple drift caused by a NTP trigger that code. > As we are only trying to compute a difference of absolute time (and n= ot system time), using a MONOTONIC_* seems much more accurate at my tas= te. >=20 > I know that's pretty picky but that could exists. That's a perfect example of where the monotonic time should be used. Th= ere=20 are a zillion instances of this pattern that could be cleaned up... :) > >I find it interesting. If you want to change more subsystems to use = ceph_time > >and use monotonic and coarse clocks in appropriate places I think th= at would be > >wonderful. It might be worthwhile to focus on the places where we us= e double to > >represent a time value. > >Please read through ceph_time.h and osdc to get a feel for it. If yo= u think it > >could use improvement, I'd be happy to hear your ideas. >=20 > You mean we could switch some of ceph_clock_now() calls to ceph_time = ?=20 > We could use coarse_mono_clock to perform that. >=20 > If you agree that switching code like the one I'm speaking is valuabl= e,=20 > I can work on it. That would be great! sage -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" i= n the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" i= n the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html