threads: align struct to CLS to avoid false sharing

Since `Thread` objects are part of a big allocation, more than one
Thread could be on a single cache line, leading to false sharing. Atomic
updates to one `Thread` could then lead to poor performance accessing
another `Thread`. Align to CLS (cache line size) to avoid this.
pull/12371/head
Victor Julien 2 years ago committed by Victor Julien
parent b75d1ab37f
commit 2af67e17bc

@ -2064,6 +2064,7 @@ static void TmThreadDumpThreads(void)
}
#endif
/* Aligned to CLS to avoid false sharing between atomic ops. */
typedef struct Thread_ {
ThreadVars *tv; /**< threadvars structure */
const char *name;
@ -2075,7 +2076,7 @@ typedef struct Thread_ {
SCTime_t sys_sec_stamp; /**< timestamp in real system
* time when the pktts was last updated. */
SCSpinlock spin;
} Thread;
} __attribute__((aligned(CLS))) Thread;
typedef struct Threads_ {
Thread *threads;

Loading…
Cancel
Save