Browse Source

[core] connection_joblist global

con->srv->joblist is expensive to traverse when cache is cold
and called from connection_handle_fdevent(); var made a global
master
Glenn Strauss 12 months ago
parent
commit
f7fc8d8d75
  1. 1
      src/base.h
  2. 2
      src/connections-glue.c
  3. 3
      src/connections.h
  4. 6
      src/server.c

1
src/base.h

@ -158,7 +158,6 @@ struct server {
buffer *tmp_buf;
connections conns;
connections *joblist;
connections joblist_A;
connections joblist_B;
connections fdwaitqueue;

2
src/connections-glue.c

@ -5,6 +5,8 @@
#include <stdlib.h>
connections *connection_joblist;
__attribute_cold__
static void connection_list_resize(connections *conns) {
conns->size += 16;

3
src/connections.h

@ -19,7 +19,8 @@ connection * connection_accepted(server *srv, server_socket *srv_socket, sock_ad
void connection_state_machine(connection *con);
#define joblist_append(con) connection_list_append((con)->srv->joblist, (con))
extern connections *connection_joblist;
#define joblist_append(con) connection_list_append(connection_joblist, (con))
void connection_list_append(connections *conns, connection *con);
#endif

6
src/server.c

@ -239,7 +239,7 @@ static server *server_init(void) {
CLEAN(tmp_buf);
#undef CLEAN
srv->joblist = &srv->joblist_A;
connection_joblist = &srv->joblist_A;
strftime_cache_reset();
@ -1856,13 +1856,13 @@ static void server_main_loop (server * const srv) {
server_process_fdwaitqueue(srv);
}
connections * const joblist = srv->joblist;
connections * const joblist = connection_joblist;
if (fdevent_poll(srv->ev, joblist->used ? 0 : 1000) > 0) {
last_active_ts = log_epoch_secs;
}
srv->joblist = (joblist == &srv->joblist_A)
connection_joblist = (joblist == &srv->joblist_A)
? &srv->joblist_B
: &srv->joblist_A;

Loading…
Cancel
Save