Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH 2/2] swim: optimize struct swim_task layout
Date: Sat,  6 Jul 2019 00:40:09 +0200	[thread overview]
Message-ID: <c0d6f98318cfbd0a2884adb443840f43d9bf5ff4.1562366340.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1562366340.git.v.shpilevoy@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)

  parent reply	other threads:[~2019-07-05 22:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05 22:40 [tarantool-patches] [PATCH 0/2] SWIM micro optimizations Vladislav Shpilevoy
2019-07-05 22:40 ` [tarantool-patches] [PATCH 1/2] swim: pool IO tasks Vladislav Shpilevoy
2019-07-05 23:01   ` [tarantool-patches] " Konstantin Osipov
2019-07-06 21:00     ` Vladislav Shpilevoy
2019-07-08  8:25       ` Konstantin Osipov
2019-07-08 18:31         ` Vladislav Shpilevoy
2019-07-08 21:54           ` Konstantin Osipov
2019-07-08 22:13             ` Vladislav Shpilevoy
2019-07-08 23:08               ` Konstantin Osipov
2019-07-09 19:43                 ` Vladislav Shpilevoy
2019-07-09 22:24                   ` Konstantin Osipov
2019-07-05 22:40 ` Vladislav Shpilevoy [this message]
2019-07-05 23:02   ` [tarantool-patches] Re: [PATCH 2/2] swim: optimize struct swim_task layout Konstantin Osipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c0d6f98318cfbd0a2884adb443840f43d9bf5ff4.1562366340.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 2/2] swim: optimize struct swim_task layout' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox