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 03A562DDAA for ; Fri, 26 Apr 2019 14:49:33 -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 6PNJCNaLTKmo for ; Fri, 26 Apr 2019 14:49:32 -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 4BC162C629 for ; Fri, 26 Apr 2019 14:49:32 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 1/1] swim: optimize struct swim memory layout Date: Fri, 26 Apr 2019 21:49:29 +0300 Message-Id: <3267e58b092d22ccfb4dd73e06ae931b2d513f0d.1556304503.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 The same problem that occured with struct swim_member, has happened with struct swim - it contains a huge structure right in the middle, struct swim_task. It consumes 1.5Kb and obviously splits the most accessible struct swim attributes into multiple cache lines. This patch moves struct swim_task to the bottom as well as other members, related to dissemination component. --- Branch: https://github.com/tarantool/tarantool/tree/gerold103/struct-swim-memory-layout src/lib/swim/swim.c | 58 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index e59e667fd..746106657 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -400,33 +400,6 @@ struct swim { * status. */ struct swim_member *self; - /** - * Members to which a message should be sent next during - * this round. - */ - struct rlist round_queue; - /** Generator of round step events. */ - struct ev_timer round_tick; - /** - * Single round step task. It is impossible to have - * multiple round steps in the same SWIM instance at the - * same time, so it is single and preallocated per SWIM - * instance. Note, that the task's packet once built at - * the beginning of a round is reused during the round - * without rebuilding on each step. But packet rebuild can - * be triggered by any update of any member. - */ - struct swim_task round_step_task; - /** - * 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. - */ - struct swim_member **shuffled; /** * Scheduler of output requests, receiver of incoming * ones. @@ -470,6 +443,37 @@ struct swim { * as long as the event TTD is non-zero. */ struct rlist dissemination_queue; + /** + * Members to which a message should be sent next during + * this round. + */ + 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. + */ + struct swim_member **shuffled; + /** + * Single round step task. It is impossible to have + * multiple round steps in the same SWIM instance at the + * same time, so it is single and preallocated per SWIM + * instance. Note, that the task's packet once built at + * the beginning of a round is reused during the round + * without rebuilding on each step. But packet rebuild can + * be triggered by any update of any member. + * + * Keep this structure at the bottom - it is huge and + * should not split other attributes into different cache + * lines. + */ + struct swim_task round_step_task; }; /** -- 2.20.1 (Apple Git-117)