mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-07 05:10:36 -04:00
Use posix_fadvise() to hint the OS when streaming raw file
Hinting the OS about our behaviour shouldn't make a big difference in performance but it will help the OS manage its disk cache and can reduce memory pressure on small systems.
This commit is contained in:
parent
7047126f51
commit
1df7ec1b7c
@ -34,6 +34,7 @@ AC_CHECK_HEADERS([sys/wait.h])
|
|||||||
AC_CHECK_HEADERS([sys/param.h])
|
AC_CHECK_HEADERS([sys/param.h])
|
||||||
AC_CHECK_HEADERS([sys/select.h])
|
AC_CHECK_HEADERS([sys/select.h])
|
||||||
AC_CHECK_HEADERS([dirent.h])
|
AC_CHECK_HEADERS([dirent.h])
|
||||||
|
AC_CHECK_FUNCS(posix_fadvise)
|
||||||
AC_CHECK_FUNCS(strptime)
|
AC_CHECK_FUNCS(strptime)
|
||||||
AC_CHECK_FUNCS(strtok_r)
|
AC_CHECK_FUNCS(strtok_r)
|
||||||
AC_CHECK_FUNCS(timegm)
|
AC_CHECK_FUNCS(timegm)
|
||||||
|
10
src/httpd.c
10
src/httpd.c
@ -577,6 +577,16 @@ httpd_stream_file(struct evhttp_request *req, int id)
|
|||||||
evhttp_send_reply_start(req, 206, "Partial Content");
|
evhttp_send_reply_start(req, 206, "Partial Content");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_POSIX_FADVISE
|
||||||
|
if (!transcode)
|
||||||
|
{
|
||||||
|
/* Hint the OS */
|
||||||
|
posix_fadvise(st->fd, st->start_offset, st->stream_size, POSIX_FADV_WILLNEED);
|
||||||
|
posix_fadvise(st->fd, st->start_offset, st->stream_size, POSIX_FADV_SEQUENTIAL);
|
||||||
|
posix_fadvise(st->fd, st->start_offset, st->stream_size, POSIX_FADV_NOREUSE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is an extension to the stock evhttp */
|
/* This is an extension to the stock evhttp */
|
||||||
req->fail_cb = stream_fail_cb;
|
req->fail_cb = stream_fail_cb;
|
||||||
req->fail_cb_arg = st;
|
req->fail_cb_arg = st;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user