mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
The "worker_aio_requests" directive.
The default value is 32 AIO simultaneous requests per worker. Previously they were hardcoded to 1024, and it was too large, since Linux allocated them early on io_setup(), but not on request itself. So with default value of /proc/sys/fs/aio-max-nr equal to 65536 only 64 worker processes could be run simultaneously. 32 AIO requests are enough for modern disks even if server runs only 1 worker.
This commit is contained in:
parent
a823c550e4
commit
c8df23cb29
@ -86,6 +86,7 @@ int eventfd(u_int initval)
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_uint_t events;
|
ngx_uint_t events;
|
||||||
|
ngx_uint_t aio_requests;
|
||||||
} ngx_epoll_conf_t;
|
} ngx_epoll_conf_t;
|
||||||
|
|
||||||
|
|
||||||
@ -133,6 +134,13 @@ static ngx_command_t ngx_epoll_commands[] = {
|
|||||||
offsetof(ngx_epoll_conf_t, events),
|
offsetof(ngx_epoll_conf_t, events),
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ ngx_string("worker_aio_requests"),
|
||||||
|
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
||||||
|
ngx_conf_set_num_slot,
|
||||||
|
0,
|
||||||
|
offsetof(ngx_epoll_conf_t, aio_requests),
|
||||||
|
NULL },
|
||||||
|
|
||||||
ngx_null_command
|
ngx_null_command
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -207,7 +215,7 @@ io_getevents(aio_context_t ctx, long min_nr, long nr, struct io_event *events,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ngx_epoll_aio_init(ngx_cycle_t *cycle)
|
ngx_epoll_aio_init(ngx_cycle_t *cycle, ngx_epoll_conf_t *epcf)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
struct epoll_event ee;
|
struct epoll_event ee;
|
||||||
@ -232,7 +240,7 @@ ngx_epoll_aio_init(ngx_cycle_t *cycle)
|
|||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (io_setup(1024, &ngx_aio_ctx) == -1) {
|
if (io_setup(epcf->aio_requests, &ngx_aio_ctx) == -1) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||||
"io_setup() failed");
|
"io_setup() failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
@ -294,7 +302,7 @@ ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer)
|
|||||||
|
|
||||||
#if (NGX_HAVE_FILE_AIO)
|
#if (NGX_HAVE_FILE_AIO)
|
||||||
|
|
||||||
ngx_epoll_aio_init(cycle);
|
ngx_epoll_aio_init(cycle, epcf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -794,6 +802,7 @@ ngx_epoll_create_conf(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
epcf->events = NGX_CONF_UNSET;
|
epcf->events = NGX_CONF_UNSET;
|
||||||
|
epcf->aio_requests = NGX_CONF_UNSET;
|
||||||
|
|
||||||
return epcf;
|
return epcf;
|
||||||
}
|
}
|
||||||
@ -805,6 +814,7 @@ ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
ngx_epoll_conf_t *epcf = conf;
|
ngx_epoll_conf_t *epcf = conf;
|
||||||
|
|
||||||
ngx_conf_init_uint_value(epcf->events, 512);
|
ngx_conf_init_uint_value(epcf->events, 512);
|
||||||
|
ngx_conf_init_uint_value(epcf->aio_requests, 32);
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user