{"action":"created","issue":{"url":"https://api.github.com/repos/litespeedtech/openlitespeed/issues/29","labels_url":"https://api.github.com/repos/litespeedtech/openlitespeed/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/litespeedtech/openlitespeed/issues/29/comments","events_url":"https://api.github.com/repos/litespeedtech/openlitespeed/issues/29/events","html_url":"https://github.com/litespeedtech/openlitespeed/issues/29","id":65921688,"number":29,"title":"mmap never uses when sendfile is enabled","user":{"login":"kopytov","id":1880291,"avatar_url":"https://avatars.githubusercontent.com/u/1880291?v=3","gravatar_id":"","url":"https://api.github.com/users/kopytov","html_url":"https://github.com/kopytov","followers_url":"https://api.github.com/users/kopytov/followers","following_url":"https://api.github.com/users/kopytov/following{/other_user}","gists_url":"https://api.github.com/users/kopytov/gists{/gist_id}","starred_url":"https://api.github.com/users/kopytov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kopytov/subscriptions","organizations_url":"https://api.github.com/users/kopytov/orgs","repos_url":"https://api.github.com/users/kopytov/repos","events_url":"https://api.github.com/users/kopytov/events{/privacy}","received_events_url":"https://api.github.com/users/kopytov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-04-02T13:13:02Z","updated_at":"2015-05-05T17:56:47Z","closed_at":"2015-05-05T17:56:47Z","body":"About \"Use sendfile\" option:\r\n\r\n> Specifies whether to use the sendfile() system call to serve static files. Static files can be served in four different ways: memory buffer cache, memory-mapped cache, plain read/write, and sendfile(). Files smaller than the Max Cached Small File Size are served from memory buffer cache. Files larger than the Max Cached Small File Size but smaller than the Max MMAP File Size will be served from memory-mapped cache. Files larger than the Max MMAP File Size will be served via plain read/write or sendfile(). Sendfile() is a \"zero copy\" system call that can greatly reduce CPU utilization when serving very large static files. Sendfile() requires an optimized network card kernel driver and thus may not be suitable for some small-vendor network adapters.\r\n\r\nI have a openLiteSpeed server with options:\r\n* Max Cached Small File Size (bytes):4096\r\n* Total Small File Cache Size (bytes): 20M\r\n* Max MMAP File Size (bytes): 256K\r\n* Total MMAP Cache Size (bytes): 40M\r\n* Use sendfile(): Yes\r\n\r\nWhen I try to download file with size 21K openLiteSpeed should use mmap. But it use sendfile:\r\n\r\n    read(21, \"GET /wp-content/themes/fozzy/intro-experiment/css/style.css HTTP/1.0\\r\\nReferer: http://dev.fozzy.com/en/intro-experiment-prices\\r\\nUser-Agent: Wget/1.12 (linux-gnu)\\r\\nAccept: */*\\r\\nHost: dev.fozzy.com\\r\\nConnection: Keep-Alive\\r\\n\\r\\n\", 2044) = 223\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/cache/supercache/dev.fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css/index.html\", 0x737dd8) = -1 ENOENT (No such file or directory)\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", {st_mode=S_IFREG|0775, st_size=20956, ...}) = 0\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", {st_mode=S_IFREG|0775, st_size=20956, ...}) = 0\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", {st_mode=S_IFREG|0775, st_size=20956, ...}) = 0\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content\", 0x7fff6c716e31, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes\", 0x7fff6c716e31, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy\", 0x7fff6c716e31, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment\", 0x7fff6c716e31, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css\", 0x7fff6c716e31, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", 0x7fff6c716e31, 4094) = -1 EINVAL (Invalid argument)\r\n    open(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", O_RDONLY) = 22\r\n    fcntl(22, F_SETFD, FD_CLOEXEC) = 0\r\n    writev(21, [{\"HTTP/1.0 200 OK\\r\\n\", 17}, {\"cache-control: public, max-age=604800\\r\\nexpires: Thu, 09 Apr 2015 09:51:37 GMT\\r\\netag: \\\"51dc-547f32c1-3f4b3\\\"\\r\\nlast-modified: Wed, 03 Dec 2014 15:56:49 GMT\\r\\ncontent-type: text/css\\r\\ncontent-length: 20956\\r\\naccept-ranges: bytes\\r\\ndate: Thu, 02 Apr 2015 09:51:37 GMT\\r\\nserver: LiteSpeed\\r\\nconnection: keep-alive\\r\\n\", 303}, {\"\\r\\n\", 2}], 3) = 322\r\n    sendfile(21, 22, [0], 20956) = 20956\r\n\r\nIf I change \"Use sendfile()\" to \"No\" then openLiteSpeed starts to use mmap for the same file:\r\n\r\n    read(21, \"GET /wp-content/themes/fozzy/intro-experiment/css/style.css HTTP/1.1\\r\\nUser-Agent: curl/7.41.0\\r\\nHost: dev.fozzy.com\\r\\nAccept: */*\\r\\n\\r\\n\", 2044) = 1\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/cache/supercache/dev.fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css/index.html\", 0x737dd8) = -1 ENOENT (No such file or directory)\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", {st_mode=S_IFREG|0775, st_size=20956, ...}) = 0\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", {st_mode=S_IFREG|0775, st_size=20956, ...}) = 0\r\n    stat(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", {st_mode=S_IFREG|0775, st_size=20956, ...}) = 0\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content\", 0x7fff413921d1, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes\", 0x7fff413921d1, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy\", 0x7fff413921d1, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment\", 0x7fff413921d1, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css\", 0x7fff413921d1, 4094) = -1 EINVAL (Invalid argument)\r\n    readlink(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", 0x7fff413921d1, 4094) = -1 EINVAL (Invalid argument)\r\n    open(\"/srv/www/dev/fozzy.com/wp-content/themes/fozzy/intro-experiment/css/style.css\", O_RDONLY) = 22\r\n    fcntl(22, F_SETFD, FD_CLOEXEC) = 0\r\n    mmap(NULL, 20956, PROT_READ, MAP_PRIVATE, 22, 0) = 0x7f2569701000\r\n    close(22)                 = 0\r\n    writev(21, [{\"HTTP/1.1 200 OK\\r\\n\", 17}, {\"cache-control: public, max-age=604800\\r\\nexpires: Thu, 09 Apr 2015 12:24:37 GMT\\r\\netag: \\\"51dc-547f32c1-3f4b3\\\"\\r\\nlast-modified: Wed, 03 Dec 2014 15:56:49 GMT\\r\\ncontent-type: text/css\\r\\ncontent-length: 20956\\r\\naccept-ranges: bytes\\r\\ndate: Thu, 02 Apr 2015 12:24:37 GMT\\r\\nserver: LiteSpeed\\r\\n\", 279}, {\"\\r\\n\", 2}, {\"@charset \\\"utf-8\\\";\\n\\n@font-face {\\n\\t\\tfont-family: 'Myriad Pro';\\n\\t\\tsrc: url('../fonts/mp-regular-webfont.eot');\\n\\t\\tsrc: url('../fonts/mp-regular-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/mp-regular-webfont.woff') format('woff'), url('../fonts/mp-regular-webfont.svg#MyriadProRegular') format('svg'), url('../fonts/mp-regular-webfont.ttf') format('truetype');\\n\\t\\tfont-weight: normal;\\n\\t\\tfont-style: normal;\\n}\\n\\n@font-face {\\n\\t\\tfont-family: 'Myriad Pro Cond';\\n\\t\\tsrc: url('../fonts/myriadpro-cond-webfont.eot');\\n\\t\\tsrc: url('../fonts/myriadpro-cond-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/myriadpro-cond-webfont.woff') format('woff'), url('../fonts/myriadpro-cond-webfont.ttf') format('truetype');\\n\\t\\tfont-weight: normal;\\n\\t\\tfont-style: normal;\\n}\\n\\n@font-face {\\n\\t\\tfont-family: 'Myriad Pro Cond';\\n\\t\\tsrc: url('../fonts/MyriadPro-SemiboldCond.eot');\\n\\t\\tsrc: url('../fonts/MyriadPro-SemiboldCond.eot?#iefix') format('embedded-opentype'), url('../fonts/MyriadPro-SemiboldCond.woff') format('woff'), url('../fonts/MyriadPro-SemiboldCond.ttf') format('truetype');\\n\\t\\tfont-weight: 600;\\n\\t\\tfont-style: normal;\\n}\\n\\n@font-face {\\n\\t\\tfont-family: 'Myriad Pro Cond';\\n\\t\\tsrc: url('../fonts/MyriadPro-SemiboldCondIt.eot');\\n\\t\\tsrc: url('../fonts/MyriadPro-SemiboldCondIt.eot?#iefix') format('embedded-opentype'), url('../fonts/MyriadPro-SemiboldCondIt.woff') format('woff'), url('../fonts/MyriadPro-SemiboldCondIt.ttf') format('truetype');\\n\\t\\tfont-weight: 600;\\n\\t\\tfont-style: italic;\\n}\\n\\n@font-face {\\n\\t\\tfont-family: 'Rouble';\\n\\t\\tsrc: \"..., 20956}], 4) = 14344\r\n    epoll_ctl(6, EPOLL_CTL_MOD, 21, {EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP, {u32=21, u64=21}}) = 0\r\n    epoll_wait(6, {}, 10, 100) = 0\r\n    epoll_wait(6, {{EPOLLOUT, {u32=21, u64=21}}}, 10, 100) = 1\r\n    writev(21, [{\" none;\\n\\t\\tmargin: 22px 0 68px 0;\\n\\t\\tpadding: 0;\\n}\\n\\n.menu2 > ul > li > ul > li {\\n\\t\\tmargin: 22px 0 0 0;\\n}\\n\\n.en .menu2 > ul > li > ul,\\n.en\r\n    menu2 > ul > li > ul > li {\\n\\t\\tmargin-top: 27px;\\n}\\n\\n.en .menu2 > ul > li > ul {\\n\\t\\tmargin-bottom: 78px;\\n}\\n\\n.btn-hold {\\n\\t\\tmargin: 60px 5px 0 5px;\\n}\\n\\n.top-text .btn-hold {\\n\\t\\tmargin-top: 56px;\\n}\\n\\n.clouds-bg h3 {\\n\\t\\tdisplay: none;\\n}\\n\\n.clouds-bg .btn-hold {\\n\\t\\tmargin-top: 66px;\\n}\\n\\n.benefits .btn-hold {\\n\\t\\tmargin-top: 63px;\\n}\\n\\n.about .btn-hold {\\n\\t\\tmargin-top: 59px;\\n}\\n\\n.btn {\\n\\t\\tdisplay: block;\\n\\t\\tposition: relative;\\n\\t\\ttext-decoration: none;\\n\\t\\tcolor: #fff;\\n\\t\\tvertical-align: top;\\n}\\n\\n.btn .t {\\n\\t\\tposition: relative;\\n\\t\\tfont-family: \\\"Myriad Pro Cond\\\", \\\"Trebuchet MS\\\", Arial, Helvetica, sans-serif;\\n\\t\\tfont-weight: 600;\\n\\t\\tfont-style: italic;\\n\\t\\tfont-size: 33px;\\n\\t\\ttext-transform: uppercase;\\n\\t\\tletter-spacing: 1px;\\n\\t\\tdisplay: inline-block;\\n\\t\\tpadding: 3px 41px 0 41px;\\n\\t\\theight: 77px;\\n\\t\\tline-height: 77px;\\n\\t\\tdisplay: block;\\n\\t\\ttext-align: left;\\n}\\n\\n.top-text .btn,\\n.top-text .btn .t {\\n\\t\\tdisplay: inline-block;\\n}\\n\\n.top-text .btn .t {\\n\\t\\tpadding-left: 87px;\\n\\t\\tpadding-right: 87px;\\n\\t\\theight: 68px;\\n\\t\\tline-height: 68px;\\n}\\n\\n.btn .b {\\n\\t\\tposition: absolute;\\n\\t\\ttop: 0;\\n\\t\\tleft: 0;\\n\\t\\tright: 0;\\n\\t\\tbottom: 0;\\n\\t\\t-moz-transform: skew(-10deg);\\n\\t\\t-o-transform: skew(-10deg);\\n\\t\\t-webkit-transform: skew(-10deg);\\n\\t\\ttransform: skew(-10deg);\\n}\\n\\n.btn:hover .b {\\nfilter:progid:DXImageTransform    Microsoft.Alpha(opacity=90);\\n\\t\\topacity: 0.9;\\n}\\n\\n.top-text .btn .b {\\n\\t\\tbackground: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHh\"..., 6910}], 1)\r\n\r\nSo it looks like a bug: openLiteSpeed ignores option \"Max MMAP File Size\" and always uses sendfile when it enabled. This behavior reduces page loading speed when it has a lot of js-, css- & small images.\r\n\r\n    $ /usr/local/lsws/bin/litespeed --version\r\n    LiteSpeed/1.3.9 Open\r\n"},"comment":{"url":"https://api.github.com/repos/litespeedtech/openlitespeed/issues/comments/99158719","html_url":"https://github.com/litespeedtech/openlitespeed/issues/29#issuecomment-99158719","issue_url":"https://api.github.com/repos/litespeedtech/openlitespeed/issues/29","id":99158719,"user":{"login":"kopytov","id":1880291,"avatar_url":"https://avatars.githubusercontent.com/u/1880291?v=3","gravatar_id":"","url":"https://api.github.com/users/kopytov","html_url":"https://github.com/kopytov","followers_url":"https://api.github.com/users/kopytov/followers","following_url":"https://api.github.com/users/kopytov/following{/other_user}","gists_url":"https://api.github.com/users/kopytov/gists{/gist_id}","starred_url":"https://api.github.com/users/kopytov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kopytov/subscriptions","organizations_url":"https://api.github.com/users/kopytov/orgs","repos_url":"https://api.github.com/users/kopytov/repos","events_url":"https://api.github.com/users/kopytov/events{/privacy}","received_events_url":"https://api.github.com/users/kopytov/received_events","type":"User","site_admin":false},"created_at":"2015-05-05T17:56:47Z","updated_at":"2015-05-05T17:56:47Z","body":"Fixed by @litespeedtech in 1.3.10."}}