From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 864994696C3 for ; Tue, 7 Apr 2020 14:48:16 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) From: Serge Petrenko In-Reply-To: <20200406083904.GB12472@atlas> Date: Tue, 7 Apr 2020 14:48:15 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <48D2B51B-221B-4E71-93A4-E6885482F57F@tarantool.org> References: <3162d52a68b95a43a0756dd2e03e4418dd80eafa.1585565637.git.sergepetrenko@tarantool.org> <0f687ed6-2a15-6b1b-1c6e-f98814f9e162@tarantool.org> <20200406083904.GB12472@atlas> Subject: Re: [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Konstantin Osipov , Vladislav Shpilevoy Cc: tml Hi! Thanks for the review! > 6 =D0=B0=D0=BF=D1=80. 2020 =D0=B3., =D0=B2 11:39, Konstantin Osipov = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0= ): >=20 > * Vladislav Shpilevoy [20/04/05 05:06]: >>> +void >>> +vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t = lsn) >>=20 >> This is probably already discussed, but why do we have general >> reset for arbitrary replica_id+lsn, and yet we have specialized >> copy_ignore0? Why this function was not called vclock_reset0() with >> replica_id =3D=3D 0 and lsn =3D=3D 0 always? vclock_reset() is used in vclock_min() later. For arbitrary replica_id = and arbitrary lsn. >=20 > It's historical. I also suggest the function should be inlined and > optimized into callers. Okay. >>=20 >>> +{ >>> + assert(lsn >=3D 0); >>> + assert(replica_id < VCLOCK_MAX); >>> + vclock->signature -=3D vclock_get(vclock, replica_id); >>> + if (lsn =3D=3D 0) { >>> + vclock->map &=3D ~(1 << replica_id); >>> + return; >>> + } >>> + vclock->lsn[replica_id] =3D lsn; >>> + vclock->map |=3D 1 << replica_id; >>> + vclock->signature +=3D lsn; >>> +} >=20 > --=20 > Konstantin Osipov, Moscow, Russia diff --git a/src/box/vclock.c b/src/box/vclock.c index ac3e9fccd..90ae27591 100644 --- a/src/box/vclock.c +++ b/src/box/vclock.c @@ -37,21 +37,6 @@ #include "diag.h" #include "tt_static.h" =20 -void -vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn) -{ - assert(lsn >=3D 0); - assert(replica_id < VCLOCK_MAX); - vclock->signature -=3D vclock_get(vclock, replica_id); - if (lsn =3D=3D 0) { - vclock->map &=3D ~(1 << replica_id); - return; - } - vclock->lsn[replica_id] =3D lsn; - vclock->map |=3D 1 << replica_id; - vclock->signature +=3D lsn; -} - int64_t vclock_follow(struct vclock *vclock, uint32_t replica_id, int64_t lsn) { diff --git a/src/box/vclock.h b/src/box/vclock.h index 2a3a29020..6438e63e4 100644 --- a/src/box/vclock.h +++ b/src/box/vclock.h @@ -192,8 +192,20 @@ vclock_inc(struct vclock *vclock, uint32_t = replica_id) * @param replica_id Replica identifier. * @param lsn Lsn to set */ -void -vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn); +static inline void +vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn) +{ + assert(lsn >=3D 0); + assert(replica_id < VCLOCK_MAX); + vclock->signature -=3D vclock_get(vclock, replica_id); + if (lsn =3D=3D 0) { + vclock->map &=3D ~(1 << replica_id); + return; + } + vclock->lsn[replica_id] =3D lsn; + vclock->map |=3D 1 << replica_id; + vclock->signature +=3D lsn; +} =20 static inline void vclock_copy(struct vclock *dst, const struct vclock *src) -- Serge Petrenko sergepetrenko@tarantool.org