diff options
author | Jan Kneschke <jan@kneschke.de> | 2005-10-18 10:39:38 +0000 |
---|---|---|
committer | Jan Kneschke <jan@kneschke.de> | 2005-10-18 10:39:38 +0000 |
commit | 4f58672a856d60bd2200c969cc13dbc074954284 (patch) | |
tree | 54449a8044072ff6239e07d8fd709450560f3121 | |
parent | e84aba5c24ad44ae95f4117781fdd9bc1e2c4c94 (diff) | |
download | lighttpd-git-4f58672a856d60bd2200c969cc13dbc074954284.tar.gz |
added a comment on possible optimizations to the code and
added #ifdef USE_MADVISE to improve experimental support for read-head via mmap()
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@791 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r-- | src/network_writev.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/network_writev.c b/src/network_writev.c index b7e4dc28..86e4f1d5 100644 --- a/src/network_writev.c +++ b/src/network_writev.c @@ -174,6 +174,27 @@ int network_write_chunkqueue_writev(server *srv, connection *con, int fd, chunkq return -1; } + + /* Optimizations for the future: + * + * adaptive mem-mapping + * the problem: + * we mmap() the whole file. If someone has alot large files and 32bit + * machine the virtual address area will be unrun and we will have a failing + * mmap() call. + * solution: + * only mmap 16M in one chunk and move the window as soon as we have finished + * the first 8M + * + * read-ahead buffering + * the problem: + * sending out several large files in parallel trashes the read-ahead of the + * kernel leading to long wait-for-seek times. + * solutions: (increasing complexity) + * 1. use madvise + * 2. use a internal read-ahead buffer in the chunk-structure + * 3. use non-blocking IO for file-transfers + * */ if (MAP_FAILED == (c->file.mmap.start = mmap(0, sce->st.st_size, PROT_READ, MAP_SHARED, c->file.fd, 0))) { log_error_write(srv, __FILE__, __LINE__, "ssbd", "mmap failed: ", @@ -181,6 +202,16 @@ int network_write_chunkqueue_writev(server *srv, connection *con, int fd, chunkq return -1; } +#ifdef USE_MADVISE + /* we should use a sliding window here and only advise on the mmaped range and not + * on the full file (waiting for adaptive mem-mapping) */ + if (0 != madvise(c->file.mmap.start, sce->st.st_size, MADV_SEQUENTIAL)) { + log_error_write(srv, __FILE__, __LINE__, "ssbd", "madvise failed: ", + strerror(errno), c->file.name, c->file.fd); + + return -1; + } +#endif close(c->file.fd); c->file.fd = -1; |