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 1967E2445E for ; Thu, 4 Jul 2019 18:22:34 -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 MlX4P_ZBkgBo for ; Thu, 4 Jul 2019 18:22:34 -0400 (EDT) Received: from smtp18.mail.ru (smtp18.mail.ru [94.100.176.155]) (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 64AB22154D for ; Thu, 4 Jul 2019 18:22:33 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 1/1] swim: push-pull dissemination Date: Fri, 5 Jul 2019 00:23:38 +0200 Message-Id: <0b77920f623b1ed8beb47112f5607e2f2e74651c.1562278974.git.v.shpilevoy@tarantool.org> 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 in the original paper says, that dissemination time of an event is O(log(N)), where N is size of the cluster. It is true, when both ping and ack messages carry dissemination and anti-entropy. Before this patch it wasn't so - only regular pings were carrying something. After this patch the SWIM module has true exponential dissemination speed. Closes #4253 --- Branch: https://github.com/tarantool/tarantool/tree/gerold103/gh-4253-swim-true-log Issue: https://github.com/tarantool/tarantool/issues/4253 src/lib/swim/swim.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index eda255e6f..7d07a353d 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -1136,15 +1136,13 @@ swim_encode_dissemination(struct swim *swim, struct swim_packet *packet) /** Encode SWIM components into a UDP packet. */ static void -swim_encode_round_msg(struct swim *swim) +swim_encode_msg(struct swim *swim, struct swim_packet *packet, + enum swim_fd_msg_type fd_type) { - struct swim_packet *packet = &swim->round_step_task.packet; - swim_packet_create(packet); char *header = swim_packet_alloc(packet, 1); int map_size = 0; map_size += swim_encode_src_uuid(swim, packet); - map_size += swim_encode_failure_detection(swim, packet, - SWIM_FD_MSG_PING); + map_size += swim_encode_failure_detection(swim, packet, fd_type); ERROR_INJECT(ERRINJ_SWIM_FD_ONLY, { mp_encode_map(header, map_size); return; @@ -1221,7 +1219,9 @@ swim_begin_step(struct ev_loop *loop, struct ev_timer *t, int events) swim_ev_timer_stop(loop, t); return; } - swim_encode_round_msg(swim); + struct swim_packet *packet = &swim->round_step_task.packet; + swim_packet_create(packet); + swim_encode_msg(swim, packet, SWIM_FD_MSG_PING); struct swim_member *m = rlist_first_entry(&swim->round_queue, struct swim_member, in_round_queue); @@ -1280,11 +1280,7 @@ swim_send_fd_msg(struct swim *swim, struct swim_task *task, swim_packet_create(&task->packet); if (proxy != NULL) swim_task_set_proxy(task, proxy); - char *header = swim_packet_alloc(&task->packet, 1); - int map_size = swim_encode_src_uuid(swim, &task->packet); - map_size += swim_encode_failure_detection(swim, &task->packet, type); - assert(map_size == 2); - mp_encode_map(header, map_size); + swim_encode_msg(swim, &task->packet, type); say_verbose("SWIM %d: schedule %s to %s", swim_fd(swim), swim_fd_msg_type_strs[type], swim_inaddr_str(dst)); swim_task_send(task, dst, &swim->scheduler); -- 2.20.1 (Apple Git-117)