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 5B1BB2BE9D for ; Wed, 24 Apr 2019 16:06:00 -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 GkmF-3d6BxJp for ; Wed, 24 Apr 2019 16:06:00 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 194D72BE99 for ; Wed, 24 Apr 2019 16:05:59 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 1/1] swim: optimize memory layout of struct swim_member Date: Wed, 24 Apr 2019 23:05:57 +0300 Message-Id: <1aa402d982fd6b8da46abfba78196c94f455ecbd.1556136325.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 Struct swim_member describes attributes of one remote member of a SWIM cluster. It is relatively often accessed. And it has two huge structures - struct swim_packet ping/ack_task. Each is 1500 bytes. When these tasks are in the middle of the structure, they split and spoil cache lines. This patch moves the whole failure detection attribute family to the bottom of the structure, and moves these two tasks to the end of layout. --- Branch: https://github.com/tarantool/tarantool/tree/gerold103/swim-struct-member-layout src/lib/swim/swim.c | 68 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 230ec52d4..7c4685a9f 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -231,40 +231,6 @@ struct swim_member { * Position in a queue of members in the current round. */ struct rlist in_round_queue; - /** - * - * Failure detection component - */ - /** - * A monotonically growing number to refute old member's - * state, characterized by a triplet - * {incarnation, status, address}. - */ - uint64_t incarnation; - /** - * How many recent pings did not receive an ack while the - * member was in the current status. When this number - * reaches a configured threshold the instance is marked - * as dead. After a few more unacknowledged it is removed - * from the member table. This counter is reset on each - * acknowledged ping, status or incarnation change. - */ - int unacknowledged_pings; - /** - * A deadline when we stop expecting a response to the - * ping and account it as unacknowledged. - */ - double ping_deadline; - /** Ready at hand regular ACK task. */ - struct swim_task ack_task; - /** Ready at hand regular PING task. */ - struct swim_task ping_task; - /** - * Position in a queue of members waiting for an ack. - * A member is added to the queue when we send a ping - * message to it. - */ - struct heap_node in_wait_ack_heap; /** * * Dissemination component @@ -344,6 +310,40 @@ struct swim_member { * time. */ struct rlist in_dissemination_queue; + /** + * + * Failure detection component + */ + /** + * A monotonically growing number to refute old member's + * state, characterized by a triplet + * {incarnation, status, address}. + */ + uint64_t incarnation; + /** + * How many recent pings did not receive an ack while the + * member was in the current status. When this number + * reaches a configured threshold the instance is marked + * as dead. After a few more unacknowledged it is removed + * from the member table. This counter is reset on each + * acknowledged ping, status or incarnation change. + */ + int unacknowledged_pings; + /** + * A deadline when we stop expecting a response to the + * ping and account it as unacknowledged. + */ + double ping_deadline; + /** + * Position in a queue of members waiting for an ack. + * A member is added to the queue when we send a ping + * message to it. + */ + struct heap_node in_wait_ack_heap; + /** Ready at hand regular ACK task. */ + struct swim_task ack_task; + /** Ready at hand regular PING task. */ + struct swim_task ping_task; }; #define mh_name _swim_table -- 2.20.1 (Apple Git-117)