Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko <sergepetrenko@tarantool.org>
To: Konstantin Osipov <kostja.osipov@gmail.com>,
	Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components
Date: Tue, 7 Apr 2020 14:48:15 +0300	[thread overview]
Message-ID: <48D2B51B-221B-4E71-93A4-E6885482F57F@tarantool.org> (raw)
In-Reply-To: <20200406083904.GB12472@atlas>

Hi! Thanks for the review!


> 6 апр. 2020 г., в 11:39, Konstantin Osipov <kostja.osipov@gmail.com> написал(а):
> 
> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org> [20/04/05 05:06]:
>>> +void
>>> +vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn)
>> 
>> 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 == 0 and lsn == 0 always?


vclock_reset() is used in vclock_min() later. For arbitrary replica_id and
arbitrary lsn.

> 
> It's historical. I also suggest the function should be inlined and
> optimized into callers.

Okay.

>> 
>>> +{
>>> +	assert(lsn >= 0);
>>> +	assert(replica_id < VCLOCK_MAX);
>>> +	vclock->signature -= vclock_get(vclock, replica_id);
>>> +	if (lsn == 0) {
>>> +		vclock->map &= ~(1 << replica_id);
>>> +		return;
>>> +	}
>>> +	vclock->lsn[replica_id] = lsn;
>>> +	vclock->map |= 1 << replica_id;
>>> +	vclock->signature += lsn;
>>> +}
> 
> -- 
> 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"
 
-void
-vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn)
-{
-       assert(lsn >= 0);
-       assert(replica_id < VCLOCK_MAX);
-       vclock->signature -= vclock_get(vclock, replica_id);
-       if (lsn == 0) {
-               vclock->map &= ~(1 << replica_id);
-               return;
-       }
-       vclock->lsn[replica_id] = lsn;
-       vclock->map |= 1 << replica_id;
-       vclock->signature += 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 >= 0);
+       assert(replica_id < VCLOCK_MAX);
+       vclock->signature -= vclock_get(vclock, replica_id);
+       if (lsn == 0) {
+               vclock->map &= ~(1 << replica_id);
+               return;
+       }
+       vclock->lsn[replica_id] = lsn;
+       vclock->map |= 1 << replica_id;
+       vclock->signature += lsn;
+}
 
 static inline void
 vclock_copy(struct vclock *dst, const struct vclock *src)


--
Serge Petrenko
sergepetrenko@tarantool.org

  reply	other threads:[~2020-04-07 11:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30 11:04 [Tarantool-patches] [PATCH v5 0/4] replication: fix local space tracking Serge Petrenko
2020-03-30 11:04 ` [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components Serge Petrenko
2020-03-30 12:56   ` Konstantin Osipov
2020-04-04 20:51   ` Vladislav Shpilevoy
2020-04-06  8:39     ` Konstantin Osipov
2020-04-07 11:48       ` Serge Petrenko [this message]
2020-03-30 11:04 ` [Tarantool-patches] [PATCH v5 2/4] replication: hide 0-th vclock components in replication responses Serge Petrenko
2020-03-30 12:56   ` Konstantin Osipov
2020-04-04 20:51   ` Vladislav Shpilevoy
2020-04-06  8:38     ` Konstantin Osipov
2020-04-07 12:22     ` Serge Petrenko
2020-03-30 11:04 ` [Tarantool-patches] [PATCH v5 3/4] gc: rely on minimal vclock components instead of signatures Serge Petrenko
2020-03-30 12:57   ` Konstantin Osipov
2020-04-04 20:51   ` Vladislav Shpilevoy
2020-04-07 12:40     ` Serge Petrenko
2020-03-30 11:04 ` [Tarantool-patches] [PATCH v5 4/4] box: start counting local space requests separately Serge Petrenko
2020-03-30 12:58   ` Konstantin Osipov
2020-04-04 20:51   ` Vladislav Shpilevoy
2020-04-07 15:48     ` Serge Petrenko
2020-03-31 11:24 ` [Tarantool-patches] [PATCH v5 0/4] replication: fix local space tracking Serge Petrenko
2020-04-04 20:51 ` Vladislav Shpilevoy
2020-04-07 11:15   ` Serge Petrenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48D2B51B-221B-4E71-93A4-E6885482F57F@tarantool.org \
    --to=sergepetrenko@tarantool.org \
    --cc=kostja.osipov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox