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 2D82124A05 for ; Fri, 5 Jul 2019 18:39:02 -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 3zpD35Z0RLXk for ; Fri, 5 Jul 2019 18:39:02 -0400 (EDT) Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 C540223F13 for ; Fri, 5 Jul 2019 18:39:01 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 2/2] swim: optimize struct swim_task layout Date: Sat, 6 Jul 2019 00:40:09 +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 Before the patch it was split in two parts by 1.5KB packet, and in the constructor it was nullifying the whole volume. Obviously, these were mistakes. The first problem breaks cache locality, the second one flushes the cache. --- src/lib/swim/swim_io.c | 3 ++- src/lib/swim/swim_io.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/swim/swim_io.c b/src/lib/swim/swim_io.c index d83f52ae9..af1092416 100644 --- a/src/lib/swim/swim_io.c +++ b/src/lib/swim/swim_io.c @@ -166,7 +166,8 @@ void swim_task_create(struct swim_task *task, swim_task_f complete, swim_task_f cancel, const char *desc) { - memset(task, 0, sizeof(*task)); + /* Do not nullify the whole structure! It is too big. */ + memset(task, 0, offsetof(struct swim_task, packet)); task->complete = complete; task->cancel = cancel; task->desc = desc; diff --git a/src/lib/swim/swim_io.h b/src/lib/swim/swim_io.h index 3e631935d..bf5a1389f 100644 --- a/src/lib/swim/swim_io.h +++ b/src/lib/swim/swim_io.h @@ -233,8 +233,6 @@ struct swim_task { * and it cancels all its tasks. */ swim_task_f cancel; - /** Packet to send. */ - struct swim_packet packet; /** Destination address. */ struct sockaddr_in dst; /** @@ -264,6 +262,8 @@ struct swim_task { }; /** Link in the task pool. */ struct stailq_entry in_pool; + /** Packet to send. */ + struct swim_packet packet; }; /** Check if @a task is already scheduled. */ -- 2.20.1 (Apple Git-117)