Skip to content
Snippets Groups Projects
Commit 31a26448 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy
Browse files

swim: optimize struct swim_task layout

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.
parent 837e114e
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment