Add the SF_NODISKIO flag to sendfile. This flag causes sendfile to be
mindful of blocking on disk I/O and instead return EBUSY when such blocking would occur. Results from the DeBox project indicate that blocking on disk I/O can slow the performance of a kqueue/poll based webserver. Using a flag such as SF_NODISKIO and throwing connections that would block to helper processes/threads helped increase performance. Currently, only the Flash webserver uses this flag, although it could probably be applied to thttpd with relative ease. Idea by: Yaoping Ruan & Vivek Pai
This commit is contained in:
parent
08fc808d7f
commit
b49d824e8b
@ -1836,7 +1836,11 @@ retry_lookup:
|
||||
* If page is not valid for what we need, initiate I/O
|
||||
*/
|
||||
|
||||
if (!pg->valid || !vm_page_is_valid(pg, pgoff, xfsize)) {
|
||||
if (pg->valid && vm_page_is_valid(pg, pgoff, xfsize)) {
|
||||
VM_OBJECT_UNLOCK(obj);
|
||||
} else if (uap->flags & SF_NODISKIO) {
|
||||
error = EBUSY;
|
||||
} else {
|
||||
int bsize, resid;
|
||||
|
||||
/*
|
||||
@ -1867,26 +1871,25 @@ retry_lookup:
|
||||
vm_page_lock_queues();
|
||||
vm_page_flag_clear(pg, PG_ZERO);
|
||||
vm_page_io_finish(pg);
|
||||
if (error) {
|
||||
vm_page_unwire(pg, 0);
|
||||
/*
|
||||
* See if anyone else might know about this page.
|
||||
* If not and it is not valid, then free it.
|
||||
*/
|
||||
if (pg->wire_count == 0 && pg->valid == 0 &&
|
||||
pg->busy == 0 && !(pg->flags & PG_BUSY) &&
|
||||
pg->hold_count == 0) {
|
||||
vm_page_busy(pg);
|
||||
vm_page_free(pg);
|
||||
}
|
||||
vm_page_unlock_queues();
|
||||
VM_OBJECT_UNLOCK(obj);
|
||||
sbunlock(&so->so_snd);
|
||||
goto done;
|
||||
}
|
||||
mbstat.sf_iocnt++;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (error) {
|
||||
vm_page_unwire(pg, 0);
|
||||
/*
|
||||
* See if anyone else might know about this page.
|
||||
* If not and it is not valid, then free it.
|
||||
*/
|
||||
if (pg->wire_count == 0 && pg->valid == 0 &&
|
||||
pg->busy == 0 && !(pg->flags & PG_BUSY) &&
|
||||
pg->hold_count == 0) {
|
||||
vm_page_busy(pg);
|
||||
vm_page_free(pg);
|
||||
}
|
||||
vm_page_unlock_queues();
|
||||
VM_OBJECT_UNLOCK(obj);
|
||||
sbunlock(&so->so_snd);
|
||||
goto done;
|
||||
}
|
||||
vm_page_unlock_queues();
|
||||
|
||||
|
@ -505,6 +505,11 @@ struct sf_hdtr {
|
||||
struct iovec *trailers; /* pointer to an array of trailer struct iovec's */
|
||||
int trl_cnt; /* number of trailer iovec's */
|
||||
};
|
||||
|
||||
/*
|
||||
* Sendfile-specific flag(s)
|
||||
*/
|
||||
#define SF_NODISKIO 0x00000001
|
||||
#endif
|
||||
|
||||
#ifndef _KERNEL
|
||||
|
Loading…
x
Reference in New Issue
Block a user