Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH 2/5] swim: sadly remove cache
Date: Thu,  4 Jul 2019 01:28:31 +0200	[thread overview]
Message-ID: <c335d87ed7722859c288004d798a099f4a2844c5.1562196102.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1562196102.git.v.shpilevoy@tarantool.org>

SWIM sends basically the same message during a round. There was
a microoptimization so as not to reassemble the message on each
step. Now it is getting harder to support that island of
perfectionism, because

    * Soon all the messages will carry all the sections,
      including indirect messages. Their body is smaller, so it
      is not possible to maintain one cached message without
      reducing its maximal size;

    * In big-clusters even without any changes a cached message
      would need to be rebuilt. This is because anti-entropy
      section won't help much unless it is being changed
      frequent enough;

    * In big clusters changes happen often enough to invalidate
      the cached message constantly, unless SWIM would had
      maintained what members are included into the cache, and
      which are not. Then change of a member, not included into
      the message, would not affect the cache. But it would
      complicate the code too much.

Part of #4253
---
 src/lib/swim/swim.c | 31 ++-----------------------------
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c
index 3bd006ad1..465e850a5 100644
--- a/src/lib/swim/swim.c
+++ b/src/lib/swim/swim.c
@@ -531,11 +531,6 @@ struct swim {
 	struct rlist round_queue;
 	/** Generator of round step events. */
 	struct ev_timer round_tick;
-	/**
-	 * True if a packet in the round step task is still valid
-	 * and can be resent on a next round step.
-	 */
-	bool is_round_packet_valid;
 	/**
 	 * Preallocated buffer to store shuffled members here at
 	 * the beginning of each round.
@@ -564,20 +559,6 @@ struct swim {
 	struct swim_task round_step_task;
 };
 
-/**
- * Mark cached round message invalid on any change of any member.
- * It triggers postponed rebuilding of the message. The round
- * packet can not be rebuilt right now because 1) invalidation can
- * occur several times in row when multiple member attributes are
- * updated, or more than one member are added, 2) the message can
- * be in fly right now in the output queue inside the scheduler.
- */
-static inline void
-swim_cached_round_msg_invalidate(struct swim *swim)
-{
-	swim->is_round_packet_valid = false;
-}
-
 /** Put the member into a list of ACK waiters. */
 static void
 swim_wait_ack(struct swim *swim, struct swim_member *member,
@@ -634,7 +615,6 @@ swim_register_event(struct swim *swim, struct swim_member *member)
 	 * SWIM paper as the best option.
 	 */
 	member->status_ttd = ceil(log2(mh_size(swim->members))) + 1;
-	swim_cached_round_msg_invalidate(swim);
 }
 
 /**
@@ -988,7 +968,6 @@ swim_new_round(struct swim *swim)
 	/* -1 for self. */
 	say_verbose("SWIM %d: start a new round with %d members", swim_fd(swim),
 		    size - 1);
-	swim_cached_round_msg_invalidate(swim);
 	swim_shuffle_members(swim);
 	rlist_create(&swim->round_queue);
 	for (int i = 0; i < size; ++i) {
@@ -1147,8 +1126,6 @@ swim_encode_dissemination(struct swim *swim, struct swim_packet *packet)
 static void
 swim_encode_round_msg(struct swim *swim)
 {
-	if (swim->is_round_packet_valid)
-		return;
 	struct swim_packet *packet = &swim->round_step_task.packet;
 	swim_packet_create(packet);
 	char *header = swim_packet_alloc(packet, 1);
@@ -1161,7 +1138,6 @@ swim_encode_round_msg(struct swim *swim)
 
 	assert(mp_sizeof_map(map_size) == 1 && map_size >= 2);
 	mp_encode_map(header, map_size);
-	swim->is_round_packet_valid = true;
 }
 
 /**
@@ -1183,14 +1159,11 @@ swim_decrease_event_ttd(struct swim *swim)
 	rlist_foreach_entry_safe(member, &swim->dissemination_queue,
 				 in_dissemination_queue,
 				 tmp) {
-		if (member->payload_ttd > 0) {
-			if (--member->payload_ttd == 0)
-				swim_cached_round_msg_invalidate(swim);
-		}
+		if (member->payload_ttd > 0)
+			--member->payload_ttd;
 		assert(member->status_ttd > 0);
 		if (--member->status_ttd == 0) {
 			rlist_del_entry(member, in_dissemination_queue);
-			swim_cached_round_msg_invalidate(swim);
 			if (member->status == MEMBER_LEFT)
 				swim_delete_member(swim, member);
 		}
-- 
2.20.1 (Apple Git-117)

  parent reply	other threads:[~2019-07-03 23:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 23:28 [tarantool-patches] [PATCH 0/5] SWIM loglog preparation Vladislav Shpilevoy
2019-07-03 23:28 ` [tarantool-patches] [PATCH 1/5] swim: fix flaky 'indirect pings' test Vladislav Shpilevoy
2019-07-04  8:20   ` [tarantool-patches] " Konstantin Osipov
2019-07-03 23:28 ` Vladislav Shpilevoy [this message]
2019-07-04  8:22   ` [tarantool-patches] Re: [PATCH 2/5] swim: sadly remove cache Konstantin Osipov
2019-07-03 23:28 ` [tarantool-patches] [PATCH 3/5] test: redo some swim tests using error injections Vladislav Shpilevoy
2019-07-04  8:23   ` [tarantool-patches] " Konstantin Osipov
2019-07-03 23:28 ` [tarantool-patches] [PATCH 4/5] swim: speed-up tests Vladislav Shpilevoy
2019-07-04  8:24   ` [tarantool-patches] " Konstantin Osipov
2019-07-03 23:28 ` [tarantool-patches] [PATCH 5/5] swim: speed-up empty payloads cluster bootstrap Vladislav Shpilevoy
2019-07-04  8:26   ` [tarantool-patches] " Konstantin Osipov
2019-07-05 22:44 ` [tarantool-patches] Re: [PATCH 0/5] SWIM loglog preparation 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=c335d87ed7722859c288004d798a099f4a2844c5.1562196102.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 2/5] swim: sadly remove cache' \
    /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