From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 625B420E3E for ; Wed, 3 Jul 2019 19:27:37 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XAdGOtOujdrw for ; Wed, 3 Jul 2019 19:27:37 -0400 (EDT) Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 251DA20E2E for ; Wed, 3 Jul 2019 19:27:37 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 2/5] swim: sadly remove cache Date: Thu, 4 Jul 2019 01:28:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: kostja@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)