]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: fd: place the lock at the beginning of struct fdtab
authorWilly Tarreau <w@1wt.eu>
Sun, 26 Nov 2017 09:41:47 +0000 (10:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 26 Nov 2017 10:10:53 +0000 (11:10 +0100)
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

index 2d8237ba18612d06329231969c6b83e935f345ee..032bab967b677062447a6b5b6a5aed347a853a25 100644 (file)
@@ -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_* */