From 5809052ae1066b0af9d36ae63608621f75d260f6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 26 Nov 2017 10:41:47 +0100 Subject: [PATCH] CLEANUP: fd: place the lock at the beginning of struct fdtab The struct is not cache line aligned but at least, every time the lock will appear in the same cache line as the fd it will benefit from being accessed first. This improves the performance by about 2% on fd-intensive workloads with 4 threads. --- include/types/fd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/types/fd.h b/include/types/fd.h index 2d8237ba1..032bab967 100644 --- a/include/types/fd.h +++ b/include/types/fd.h @@ -92,10 +92,10 @@ enum fd_states { /* info about one given fd */ struct fdtab { + __decl_hathreads(HA_SPINLOCK_T lock); + unsigned long thread_mask; /* mask of thread IDs authorized to process the task */ void (*iocb)(int fd); /* I/O handler */ void *owner; /* the connection or listener associated with this fd, NULL if closed */ - unsigned long thread_mask; /* mask of thread IDs authorized to process the task */ - __decl_hathreads(HA_SPINLOCK_T lock); unsigned int cache; /* position+1 in the FD cache. 0=not in cache. */ unsigned char state; /* FD state for read and write directions (2*3 bits) */ unsigned char ev; /* event seen in return of poll() : FD_POLL_* */