From owner-svn-doc-head@freebsd.org Mon Jan 18 20:13:02 2016 Return-Path: Delivered-To: svn-doc-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29EDCA861F0; Mon, 18 Jan 2016 20:13:02 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E06FA10BF; Mon, 18 Jan 2016 20:13:01 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0IKD0Om089440; Mon, 18 Jan 2016 20:13:00 GMT (envelope-from bjk@FreeBSD.org) Received: (from bjk@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0IKD0An089439; Mon, 18 Jan 2016 20:13:00 GMT (envelope-from bjk@FreeBSD.org) Message-Id: <201601182013.u0IKD0An089439@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bjk set sender to bjk@FreeBSD.org using -f From: Benjamin Kaduk Date: Mon, 18 Jan 2016 20:13:00 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r48055 - head/en_US.ISO8859-1/htdocs/news/status X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the doc tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2016 20:13:02 -0000 Author: bjk Date: Mon Jan 18 20:13:00 2016 New Revision: 48055 URL: https://svnweb.freebsd.org/changeset/doc/48055 Log: Add sendfile entry from glebius Modified: head/en_US.ISO8859-1/htdocs/news/status/report-2015-10-2015-12.xml Modified: head/en_US.ISO8859-1/htdocs/news/status/report-2015-10-2015-12.xml ============================================================================== --- head/en_US.ISO8859-1/htdocs/news/status/report-2015-10-2015-12.xml Mon Jan 18 18:42:46 2016 (r48054) +++ head/en_US.ISO8859-1/htdocs/news/status/report-2015-10-2015-12.xml Mon Jan 18 20:13:00 2016 (r48055) @@ -3631,4 +3631,114 @@ + + + Sendfile(2) Improvements + + + + + Gleb + Smirnoff + + glebius@FreeBSD.org + + + + + Commit to Head + Slides + Presentation (in Russian) + + + +

The sendfile(2) system call was introduced in + 1998 as an alternative to a traditional + read(2)/write(2) loop, speeding up server + performance by a factor of ten at the time. Since it was adopted + by all major operating systems, it is now used by any serious web + server software. Wherever there is high traffic, there is + sendfile(2) under the hood.

+ +

Now, with &os; 11, we are making the next revolutinary step + in serving traffic. sendfile(2) no longer blocks waiting + on disk I/O. Instead, it immediately returns control to the + application, performing the necessary I/O in the background. The + original sendfile(2) waited for the disk read operation + to complete and then put the data that was read into the socket, + then returned to userspace. If a web server serves thousands of + clients, with thousands of requests, in order to avoid stalls it + needed to spawn extra contexts from which to run + sendfile(2). Alternatively, it could use special tricks + like the SF_NODISKIO flag that forces + sendfile(2) to serve only content that is cached in + memory. Now, these tricks are in the past, and a web server can + simply use sendfile(2) as it would use write(2), + withouth any extra care. The new sendfile cuts out the overhead + of extra contexts, short writes, and extra syscalls to prepopulate + the cache, bringing performance to new level.

+ +

The new syscall is built on top of two new features + introduced in the kernel. The first one is an asynchronous VM + pager interface, and the corresponding + VOP_GETPAGES_ASYNC() file system method for UFS. The + second one is the concept of "not ready" data in + sockets. When sendfile(2) is called, first + VOP_GETPAGES_ASYNC() is called, which dispatches I/O requests for + completion. Then, buffers with pages to be populated are put into + the socket buffer, but flagged as not-yet-ready. Then control + immediately returns to the application. When the I/O is finished, + the buffers are marked as ready, and the socket is activated to + continue transmission.

+ +

Additional features of the new sendfile are new flags that + provide an application with extra control over the transmitted + content. Now it is possible to prevent caching of content in + memory, which is useful when it is known that the content is + unlikely to be reused any time soon. In such cases, it is better + to let the associated storage be freed, rather than puting the + data in cache. It is also possible to specify a readahead with + every syscall, if the application can predict client behavior.

+ +

The new sendfile(2) is a drop-in replacement, API + and ABI compatible with old one. Applications do not even need to + recompile in order to benefit from the new implementation.

+ +

This work is a joint effort between two companies: NGINX, + Inc., and Netflix. There were many people involved in the + project. At its initial stage, when no code was yet written, the + idea of such an asynchronous drop-in replacement was discussed + amongst &a.glebius;, &a.scottl;, &a.kib;, &a.adrian;, and Igor + Sysoev. The initial prototype was coded by Gleb under the + supervision of Kostik on the VM parts of patch, and under constant + pressure from Igor, who demanded that nginx be capable of running + with the new sendfile(2) with no modifications. The + prototype demonstrated good performance and stability and quickly + went into Netflix production in late 2014. During 2015, the code + matured and continued serving production traffic at Netflix. + &a.scottl;, &a.rrs;, &a.emax;, and &a.gallatin; added their + contributions to the code.

+ +

Now we are releasing the code behind our success to the + &os; community, making it available to all &os; users + worldwide!

+ + + + Netflix + + + + NGINX, Inc. + + + + +

SSL_sendfile() — an extension to the new + sendfile(2) that allows uploading session keys to the + kernel, and then using sendfile(2) on an SSL-enabled + socket.

+
+
+