Avoid accessing tls data
The thread id is copied to a local variable to avoid having __tls_get_addr from unnecessarily being called over and over again. Together that used to amount to some 1% of the execution time.
This commit is contained in:
@ -94,7 +94,7 @@ typedef struct fake_event
|
|||||||
struct fake_event *next; /*< The next event */
|
struct fake_event *next; /*< The next event */
|
||||||
} fake_event_t;
|
} fake_event_t;
|
||||||
|
|
||||||
thread_local int thread_id; /**< This thread's ID */
|
thread_local int current_thread_id; /**< This thread's ID */
|
||||||
static int *epoll_fd; /*< The epoll file descriptor */
|
static int *epoll_fd; /*< The epoll file descriptor */
|
||||||
static int next_epoll_fd = 0; /*< Which thread handles the next DCB */
|
static int next_epoll_fd = 0; /*< Which thread handles the next DCB */
|
||||||
static fake_event_t **fake_events; /*< Thread-specific fake event queue */
|
static fake_event_t **fake_events; /*< Thread-specific fake event queue */
|
||||||
@ -653,9 +653,11 @@ poll_waitevents(void *arg)
|
|||||||
{
|
{
|
||||||
struct epoll_event events[MAX_EVENTS];
|
struct epoll_event events[MAX_EVENTS];
|
||||||
int i, nfds, timeout_bias = 1;
|
int i, nfds, timeout_bias = 1;
|
||||||
thread_id = (intptr_t)arg;
|
current_thread_id = (intptr_t)arg;
|
||||||
int poll_spins = 0;
|
int poll_spins = 0;
|
||||||
|
|
||||||
|
int thread_id = current_thread_id;
|
||||||
|
|
||||||
if (thread_data)
|
if (thread_data)
|
||||||
{
|
{
|
||||||
thread_data[thread_id].state = THREAD_IDLE;
|
thread_data[thread_id].state = THREAD_IDLE;
|
||||||
@ -1635,7 +1637,7 @@ void poll_send_message(enum poll_message msg, void *data)
|
|||||||
|
|
||||||
for (int i = 0; i < nthr; i++)
|
for (int i = 0; i < nthr; i++)
|
||||||
{
|
{
|
||||||
if (i != thread_id)
|
if (i != current_thread_id)
|
||||||
{
|
{
|
||||||
while (poll_msg[i] & msg)
|
while (poll_msg[i] & msg)
|
||||||
{
|
{
|
||||||
@ -1650,6 +1652,8 @@ void poll_send_message(enum poll_message msg, void *data)
|
|||||||
|
|
||||||
static void poll_check_message()
|
static void poll_check_message()
|
||||||
{
|
{
|
||||||
|
int thread_id = current_thread_id;
|
||||||
|
|
||||||
if (poll_msg[thread_id] & POLL_MSG_CLEAN_PERSISTENT)
|
if (poll_msg[thread_id] & POLL_MSG_CLEAN_PERSISTENT)
|
||||||
{
|
{
|
||||||
SERVER *server = (SERVER*)poll_msg_data;
|
SERVER *server = (SERVER*)poll_msg_data;
|
||||||
|
Reference in New Issue
Block a user