Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(996)

Issue 4528084: code review 4528084: syscall,io,net,os,http: sendfile support (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 10 months ago by bradfitz
Modified:
13 years, 10 months ago
Reviewers:
eds2, iant, iant2, adg, mattn, golang-dev
CC:
golang-dev
Visibility:
Public.

Description

io,net,os,http: sendfile support Speeds up static fileserver, avoiding copies userspace. Basic design: * io.Copy checks if its read source is a SendfileSource and its write destination is a SendfileDestination. If so, asks those for their underlying fds and if that succeeds, does the sendfile. (io.Copyn not yet done) Numbers: downloading 14 MB AppEngine Go SDK with ab (Apache Bench) with 5 threads: Before/after numbers: CPU: user 0m3.910s sys 0m23.650s -> user 0m0.720s sys 0m4.890s Time taken for tests: 8.906 seconds -> Time taken for tests: 8.545 seconds Percentage of the requests served within a certain time (ms) 50% 44 66% 45 75% 46 80% 46 90% 48 95% 51 98% 59 99% 71 100 74 (longest request) -> 50% 42 66% 43 75% 43 80% 44 90% 46 95% 57 98% 62 99% 63 100% 64 (longest request)

Patch Set 1 #

Patch Set 2 : diff -r f807f74a59b0 https://go.googlecode.com/hg #

Patch Set 3 : diff -r f807f74a59b0 https://go.googlecode.com/hg #

Total comments: 11

Patch Set 4 : diff -r 364e36aeec98 https://go.googlecode.com/hg #

Unified diffs Side-by-side diffs Delta from patch set Stats (+83 lines, -1 line) Patch
M src/pkg/http/fs.go View 1 1 chunk +5 lines, -1 line 0 comments Download
M src/pkg/http/server.go View 1 1 chunk +12 lines, -0 lines 0 comments Download
M src/pkg/io/io.go View 1 2 3 3 chunks +46 lines, -0 lines 0 comments Download
M src/pkg/net/fd.go View 1 1 chunk +4 lines, -0 lines 0 comments Download
M src/pkg/net/tcpsock.go View 1 1 chunk +8 lines, -0 lines 0 comments Download
M src/pkg/os/file.go View 1 1 chunk +8 lines, -0 lines 0 comments Download

Messages

Total messages: 14
bradfitz
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg
13 years, 10 months ago (2011-05-20 00:07:17 UTC) #1
bradfitz
This is still rough (not much in the way of comments of tests) but if ...
13 years, 10 months ago (2011-05-20 00:17:57 UTC) #2
adg
http://codereview.appspot.com/4528084/diff/4011/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4528084/diff/4011/src/pkg/http/server.go#newcode122 src/pkg/http/server.go:122: func (r *response) SendfileDestinationFd() (fd int, waitfn func(), err ...
13 years, 10 months ago (2011-05-20 01:46:19 UTC) #3
bradfitz
http://codereview.appspot.com/4528084/diff/4011/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4528084/diff/4011/src/pkg/http/server.go#newcode122 src/pkg/http/server.go:122: func (r *response) SendfileDestinationFd() (fd int, waitfn func(), err ...
13 years, 10 months ago (2011-05-20 02:56:07 UTC) #4
eds2
I realize this is a work in progress and I think it's worthwhile, but please ...
13 years, 10 months ago (2011-05-20 03:04:36 UTC) #5
adg
On 20 May 2011 12:56, <bradfitz@golang.org> wrote: > > http://codereview.appspot.com/4528084/diff/4011/src/pkg/http/server.go > File src/pkg/http/server.go (right): > ...
13 years, 10 months ago (2011-05-20 03:06:46 UTC) #6
bradfitz
On Thu, May 19, 2011 at 8:06 PM, Andrew Gerrand <adg@golang.org> wrote: > On 20 ...
13 years, 10 months ago (2011-05-20 03:13:59 UTC) #7
bradfitz
On Thu, May 19, 2011 at 8:04 PM, Evan Shaw <edsrzf@gmail.com> wrote: > I realize ...
13 years, 10 months ago (2011-05-20 03:15:51 UTC) #8
adg
On 20 May 2011 13:13, Brad Fitzpatrick <bradfitz@golang.org> wrote: >> In other words, http shouldn't ...
13 years, 10 months ago (2011-05-20 03:20:00 UTC) #9
bradfitz
On Thu, May 19, 2011 at 8:19 PM, Andrew Gerrand <adg@golang.org> wrote: > On 20 ...
13 years, 10 months ago (2011-05-20 03:25:58 UTC) #10
mattn
Sorry about that I sent few messages into google groups. We can port it to ...
13 years, 10 months ago (2011-05-20 03:54:50 UTC) #11
iant
I guess it seems to me that this can fit into the existing ReadFrom interface. ...
13 years, 10 months ago (2011-05-20 05:26:56 UTC) #12
bradfitz
On Thu, May 19, 2011 at 10:26 PM, <iant@golang.org> wrote: > ReadFrom can simply ask ...
13 years, 10 months ago (2011-05-20 19:59:09 UTC) #13
iant2
13 years, 10 months ago (2011-05-21 03:23:22 UTC) #14
Brad Fitzpatrick <bradfitz@golang.org> writes:

> On Thu, May 19, 2011 at 10:26 PM, <iant@golang.org> wrote:
>
>>  ReadFrom can simply ask whether its
>> argument is a os.File.  If it is, call the Fd() method, and try to call
>> sendfile.  If it is not an os.File, or if sendfile fails, fall back to
>> simply copying the data.  I suppose we could make the copying a little
>> simpler if we split up io.Copy to create io.RawCopy or something which
>> would do the copy without checking for ReadFrom.
>>
>
> Do you like that more (an io.RawCopy) more than an an ErrDeclined returned
> value?

Personally, I do.  My leaning is to have an error be an error.  If we
add ErrDeclined, then every caller has to handle that possibility;
caller can no longer simply return the error if there is one.  Since
every caller would have to handle it, if we want to go this route, I
would rather add it as a third result parameter, rather than overloading
the error result.

> With ErrDeclined, io.Copy[n] could proceed to its next step:
> ...
> without http.response and TCPConn needing to try that check first, or
> without them knowing to need to call
> io.{RawCopy,RawCopyButWriterToCheckFirst}.

It's a fair point.  I don't have a good answer offhand.


As a separate issue, we'll have to consider adding a ReadFromN method to
efficiently handle io.CopyN.

Ian
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b