Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Sergey Petrenko" <sergepetrenko@tarantool.org>
To: "Sergey Petrenko" <sergepetrenko@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org,
	"Vladislav Shpilevoy" <v.shpilevoy@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 4/5] vclock: ignore 0th component in comparisons.
Date: Tue, 24 Dec 2019 01:58:56 +0300	[thread overview]
Message-ID: <1577141936.135974049@f472.i.mail.ru> (raw)
In-Reply-To: <1577136394.479594081@f542.i.mail.ru>




>Вторник, 24 декабря 2019, 0:26 +03:00 от Sergey Petrenko <sergepetrenko@tarantool.org>:
>
>Hi! Thanks for the review.
>
>
>>Воскресенье, 22 декабря 2019, 20:59 +03:00 от Vladislav Shpilevoy < v.shpilevoy@tarantool.org >:
>>
>>Thanks for the patch!
>>
>>See 2 comments below.
>>
>>On 15/12/2019 21:58, sergepetrenko wrote:
>>> 0th vclock component will be used to count replica-local rows of an
>>> anonymous replica. These rows won't be replicated and different
>>> instances will have different values in vclock[0]. So ignore 0th
>>> component in comparisons.
>>
>>1. Lets add 'Part of #3186'.
>Done.
>
>>
>>
>>> ---
>>>  src/box/vclock.h    | 7 +++++++
>>>  test/unit/vclock.cc | 8 ++++----
>>>  2 files changed, 11 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/src/box/vclock.h b/src/box/vclock.h
>>> index b5eddcf8b..5dddbd173 100644
>>> --- a/src/box/vclock.h
>>> +++ b/src/box/vclock.h
>>> @@ -281,6 +281,13 @@ vclock_compare(const struct vclock *a, const struct vclock *b)
>>> 
>>>  for (size_t replica_id = bit_iterator_next(&it); replica_id < VCLOCK_MAX;
>>>       replica_id = bit_iterator_next(&it)) {
>>> +/*
>>> + * Ignore 0-th component in comparisons.
>>> + * It is empty for normal replicas and should
>>> + * be ignored for anonymous ones.
>>> + */
>>> +if (replica_id == 0)
>>> +continue;
>>> 
>>>  int64_t lsn_a = vclock_get(a, replica_id);
>>>  int64_t lsn_b = vclock_get(b, replica_id);
>>
>>2. Consider this refactoring in order not to compare replica_id
>>with 0 on each iteration:
>>
>>================================================================================
>>
>>diff --git a/src/box/vclock.h b/src/box/vclock.h
>>index 5dddbd173..fc6aeb724 100644
>>--- a/src/box/vclock.h
>>+++ b/src/box/vclock.h
>>@@ -279,16 +279,15 @@ vclock_compare(const struct vclock *a, const struct vclock *b)
>> struct bit_iterator it;
>> bit_iterator_init(&it, &map, sizeof(map), true);
>>
>>-for (size_t replica_id = bit_iterator_next(&it); replica_id < VCLOCK_MAX;
>>-     replica_id = bit_iterator_next(&it)) {
>>-/*
>>- * Ignore 0-th component in comparisons.
>>- * It is empty for normal replicas and should
>>- * be ignored for anonymous ones.
>>- */
>>-if (replica_id == 0)
>>-continue;
>>-
>>+size_t replica_id = bit_iterator_next(&it);
>>+/*
>>+ * Ignore 0-th component in comparisons. It is empty for
>>+ * normal replicas and should be ignored for anonymous
>>+ * ones.
>>+ */
>>+if (replica_id == 0)
>>+replica_id = bit_iterator_next(&it);
>>+for (; replica_id < VCLOCK_MAX; replica_id = bit_iterator_next(&it)) {
>> int64_t lsn_a = vclock_get(a, replica_id);
>> int64_t lsn_b = vclock_get(b, replica_id);
>> le = le && lsn_a <= lsn_b;
>
>Fixed:
>
>diff --git a/src/box/vclock.h b/src/box/vclock.h
>index 5dddbd173..8df628c62 100644
>--- a/src/box/vclock.h
>+++ b/src/box/vclock.h
>@@ -279,15 +279,16 @@ vclock_compare(const struct vclock *a, const struct vclock *b)
> struct bit_iterator it;
> bit_iterator_init(&it, &map, sizeof(map), true);
> 
>+/*
>+ * Ignore 0-th component in comparisons.
>+ * It is empty for normal replicas and should
>+ * be ignored for anonymous ones.
>+ */
>+if (replica_id == 0)
>+replica_id = bit_iterator_next(&it);
>+
> for (size_t replica_id = bit_iterator_next(&it); replica_id < VCLOCK_MAX;
>      replica_id = bit_iterator_next(&it)) {
>-/*
>- * Ignore 0-th component in comparisons.
>- * It is empty for normal replicas and should
>- * be ignored for anonymous ones.
>- */
>-if (replica_id == 0)
>-continue;
> 
> int64_t lsn_a = vclock_get(a, replica_id);
> int64_t lsn_b = vclock_get(b, replica_id);
>
>>
>>
>>================================================================================
>
>
>-- 
>Sergey Petrenko

Sorry, fixed

diff --git a/src/box/vclock.h b/src/box/vclock.h
index 8df628c62..35ba6284c 100644
--- a/src/box/vclock.h
+++ b/src/box/vclock.h
@@ -279,6 +279,7 @@ vclock_compare(const struct vclock *a, const struct vclock *b)
 struct bit_iterator it;
 bit_iterator_init(&it, &map, sizeof(map), true);
 
+size_t replica_id = bit_iterator_next(&it);
 /*
  * Ignore 0-th component in comparisons.
  * It is empty for normal replicas and should
@@ -287,8 +288,7 @@ vclock_compare(const struct vclock *a, const struct vclock *b)
 if (replica_id == 0)
 replica_id = bit_iterator_next(&it);
 
-for (size_t replica_id = bit_iterator_next(&it); replica_id < VCLOCK_MAX;
-     replica_id = bit_iterator_next(&it)) {
+for (; replica_id < VCLOCK_MAX; replica_id = bit_iterator_next(&it)) {
 
 int64_t lsn_a = vclock_get(a, replica_id);
 int64_t lsn_b = vclock_get(b, replica_id);

-- 
Sergey Petrenko

  reply	other threads:[~2019-12-23 22:58 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-15 20:56 [Tarantool-patches] [PATCH 0/5] introduce anonymous replicas sergepetrenko
2019-12-15 20:58 ` [Tarantool-patches] [PATCH 1/5] box: update comment describing join protocol sergepetrenko
2019-12-22 17:58   ` Vladislav Shpilevoy
2019-12-23 21:12     ` Sergey Petrenko
2019-12-15 20:58 ` [Tarantool-patches] [PATCH 2/5] replication: do not decode replicaset uuid when processing a subscribe sergepetrenko
2019-12-15 20:58 ` [Tarantool-patches] [PATCH 3/5] applier: split join processing into two stages sergepetrenko
2019-12-22 17:59   ` Vladislav Shpilevoy
2019-12-23 22:10     ` Sergey Petrenko
2019-12-24 15:50       ` Vladislav Shpilevoy
2019-12-15 20:58 ` [Tarantool-patches] [PATCH 4/5] vclock: ignore 0th component in comparisons sergepetrenko
2019-12-22 17:59   ` Vladislav Shpilevoy
2019-12-23 21:26     ` Sergey Petrenko
2019-12-23 22:58       ` Sergey Petrenko [this message]
2019-12-26  4:43   ` Konstantin Osipov
2019-12-26  5:02     ` Konstantin Osipov
2019-12-27 12:56       ` Sergey Petrenko
2019-12-27 13:31         ` Konstantin Osipov
2019-12-27 13:48           ` Sergey Petrenko
2019-12-27 14:40             ` Konstantin Osipov
2019-12-15 20:58 ` [Tarantool-patches] [PATCH 5/5] replication: introduce anonymous replica sergepetrenko
2019-12-16 13:28   ` Serge Petrenko
2019-12-20 12:06     ` Serge Petrenko
2019-12-22 17:58   ` Vladislav Shpilevoy
2019-12-25 12:40     ` Sergey Petrenko
2019-12-25 18:23       ` Vladislav Shpilevoy
2019-12-26 16:08         ` Sergey Petrenko
2019-12-15 21:00 ` [Tarantool-patches] [PATCH 0/5] introduce anonymous replicas Sergey Petrenko
2019-12-18  7:49 ` Georgy Kirichenko
2019-12-20 12:07   ` Serge Petrenko
2019-12-20 12:17     ` Serge Petrenko
2019-12-22 17:59 ` Vladislav Shpilevoy

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=1577141936.135974049@f472.i.mail.ru \
    --to=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 4/5] vclock: ignore 0th component in comparisons.' \
    /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