read_ahead
Igor Sysoev
12 years ago
169 | 169 |
CRYPT_LIB="-lcrypt"
|
170 | 170 |
fi
|
171 | 171 |
fi
|
|
172 |
|
|
173 |
|
|
174 |
ngx_feature="F_READAHEAD"
|
|
175 |
ngx_feature_name="NGX_HAVE_F_READAHEAD"
|
|
176 |
ngx_feature_run=no
|
|
177 |
ngx_feature_incs="#include <fcntl.h>"
|
|
178 |
ngx_feature_path=
|
|
179 |
ngx_feature_libs=
|
|
180 |
ngx_feature_test="fcntl(0, F_READAHEAD, 1);"
|
|
181 |
. auto/feature
|
|
182 |
|
|
183 |
|
|
184 |
ngx_feature="posix_fadvise()"
|
|
185 |
ngx_feature_name="NGX_HAVE_POSIX_FADVISE"
|
|
186 |
ngx_feature_run=no
|
|
187 |
ngx_feature_incs="#include <fcntl.h>"
|
|
188 |
ngx_feature_path=
|
|
189 |
ngx_feature_libs=
|
|
190 |
ngx_feature_test="posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);"
|
|
191 |
. auto/feature
|
172 | 192 |
|
173 | 193 |
|
174 | 194 |
ngx_feature="O_DIRECT"
|
14 | 14 |
* directories stat() info;
|
15 | 15 |
* files and directories errors: not found, access denied, etc.
|
16 | 16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#define NGX_MIN_READ_AHEAD (128 * 1024)
|
17 | 20 |
|
18 | 21 |
|
19 | 22 |
static void ngx_open_file_cache_cleanup(void *data);
|
|
523 | 526 |
} else {
|
524 | 527 |
of->fd = fd;
|
525 | 528 |
|
|
529 |
if (of->read_ahead && ngx_file_size(&fi) > NGX_MIN_READ_AHEAD) {
|
|
530 |
if (ngx_read_ahead(fd, of->read_ahead) == NGX_ERROR) {
|
|
531 |
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
|
532 |
ngx_read_ahead_n " \"%s\" failed", name);
|
|
533 |
}
|
|
534 |
}
|
|
535 |
|
526 | 536 |
if (of->directio <= ngx_file_size(&fi)) {
|
527 | 537 |
if (ngx_directio_on(fd) == NGX_FILE_ERROR) {
|
528 | 538 |
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
105 | 105 |
|
106 | 106 |
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
107 | 107 |
|
|
108 |
of.read_ahead = clcf->read_ahead;
|
108 | 109 |
of.directio = clcf->directio;
|
109 | 110 |
of.valid = clcf->open_file_cache_valid;
|
110 | 111 |
of.min_uses = clcf->open_file_cache_min_uses;
|
123 | 123 |
|
124 | 124 |
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
125 | 125 |
|
|
126 |
of.read_ahead = clcf->read_ahead;
|
126 | 127 |
of.directio = clcf->directio;
|
127 | 128 |
of.valid = clcf->open_file_cache_valid;
|
128 | 129 |
of.min_uses = clcf->open_file_cache_min_uses;
|
204 | 204 |
|
205 | 205 |
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
206 | 206 |
|
|
207 |
of.read_ahead = clcf->read_ahead;
|
207 | 208 |
of.directio = clcf->directio;
|
208 | 209 |
of.valid = clcf->open_file_cache_valid;
|
209 | 210 |
of.min_uses = clcf->open_file_cache_min_uses;
|
90 | 90 |
|
91 | 91 |
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
92 | 92 |
|
|
93 |
of.read_ahead = clcf->read_ahead;
|
93 | 94 |
of.directio = clcf->directio;
|
94 | 95 |
of.valid = clcf->open_file_cache_valid;
|
95 | 96 |
of.min_uses = clcf->open_file_cache_min_uses;
|
647 | 647 |
|
648 | 648 |
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
649 | 649 |
|
|
650 |
of.read_ahead = clcf->read_ahead;
|
650 | 651 |
of.directio = clcf->directio;
|
651 | 652 |
of.valid = clcf->open_file_cache_valid;
|
652 | 653 |
of.min_uses = clcf->open_file_cache_min_uses;
|
407 | 407 |
|
408 | 408 |
#endif
|
409 | 409 |
|
|
410 |
{ ngx_string("read_ahead"),
|
|
411 |
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
412 |
ngx_conf_set_size_slot,
|
|
413 |
NGX_HTTP_LOC_CONF_OFFSET,
|
|
414 |
offsetof(ngx_http_core_loc_conf_t, read_ahead),
|
|
415 |
NULL },
|
|
416 |
|
410 | 417 |
{ ngx_string("directio"),
|
411 | 418 |
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
412 | 419 |
ngx_http_core_directio,
|
|
2956 | 2963 |
#if (NGX_HAVE_FILE_AIO)
|
2957 | 2964 |
lcf->aio = NGX_CONF_UNSET;
|
2958 | 2965 |
#endif
|
|
2966 |
lcf->read_ahead = NGX_CONF_UNSET_SIZE;
|
2959 | 2967 |
lcf->directio = NGX_CONF_UNSET;
|
2960 | 2968 |
lcf->directio_alignment = NGX_CONF_UNSET;
|
2961 | 2969 |
lcf->tcp_nopush = NGX_CONF_UNSET;
|
|
3157 | 3165 |
#if (NGX_HAVE_FILE_AIO)
|
3158 | 3166 |
ngx_conf_merge_value(conf->aio, prev->aio, 0);
|
3159 | 3167 |
#endif
|
|
3168 |
ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0);
|
3160 | 3169 |
ngx_conf_merge_off_value(conf->directio, prev->directio,
|
3161 | 3170 |
NGX_MAX_OFF_T_VALUE);
|
3162 | 3171 |
ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment,
|
331 | 331 |
size_t limit_rate; /* limit_rate */
|
332 | 332 |
size_t limit_rate_after; /* limit_rate_after */
|
333 | 333 |
size_t sendfile_max_chunk; /* sendfile_max_chunk */
|
|
334 |
size_t read_ahead; /* read_ahead */
|
334 | 335 |
|
335 | 336 |
ngx_msec_t client_body_timeout; /* client_body_timeout */
|
336 | 337 |
ngx_msec_t send_timeout; /* send_timeout */
|
280 | 280 |
of.min_uses = clcf->open_file_cache_min_uses;
|
281 | 281 |
of.events = clcf->open_file_cache_events;
|
282 | 282 |
of.directio = NGX_OPEN_FILE_DIRECTIO_OFF;
|
|
283 |
of.read_ahead = clcf->read_ahead;
|
283 | 284 |
|
284 | 285 |
if (ngx_open_cached_file(clcf->open_file_cache, &c->file.name, &of, r->pool)
|
285 | 286 |
!= NGX_OK)
|
253 | 253 |
#define ngx_unlock_fd_n "fcntl(F_SETLK, F_UNLCK)"
|
254 | 254 |
|
255 | 255 |
|
|
256 |
#if (NGX_HAVE_F_READAHEAD)
|
|
257 |
|
|
258 |
#define NGX_HAVE_READ_AHEAD 1
|
|
259 |
|
|
260 |
#define ngx_read_ahead(fd, n) fcntl(fd, F_READAHEAD, (int) n)
|
|
261 |
#define ngx_read_ahead_n "fcntl(fd, F_READAHEAD)"
|
|
262 |
|
|
263 |
#elif (NGX_HAVE_POSIX_FADVISE)
|
|
264 |
|
|
265 |
#define NGX_HAVE_READ_AHEAD 1
|
|
266 |
|
|
267 |
#define ngx_read_ahead(fd, n) posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL)
|
|
268 |
#define ngx_read_ahead_n "posix_fadvise(POSIX_FADV_SEQUENTIAL)"
|
|
269 |
|
|
270 |
#else
|
|
271 |
|
|
272 |
#define ngx_read_ahead(fd, n) 0
|
|
273 |
#define ngx_read_ahead_n "ngx_read_ahead_n"
|
|
274 |
|
|
275 |
#endif
|
|
276 |
|
|
277 |
|
256 | 278 |
#if (NGX_HAVE_O_DIRECT)
|
257 | 279 |
|
258 | 280 |
ngx_int_t ngx_directio_on(ngx_fd_t fd);
|
231 | 231 |
ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *ce,
|
232 | 232 |
off_t offset, ngx_pool_t *pool);
|
233 | 233 |
|
|
234 |
ngx_int_t ngx_read_ahead(ngx_fd_t fd, size_t n);
|
|
235 |
#define ngx_read_ahead_n "ngx_read_ahead_n"
|
234 | 236 |
|
235 | 237 |
ngx_int_t ngx_directio_on(ngx_fd_t fd);
|
236 | 238 |
#define ngx_directio_on_n "ngx_directio_on_n"
|