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

Issue 4543071: code review 4543071: io, net, http: sendfile support (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 2 months ago by bradfitz
Modified:
14 years, 2 months ago
Reviewers:
gburd
CC:
iant, rsc, bradfitzgoog, golang-dev
Visibility:
Public.

Description

io, net, http: sendfile support Speeds up static fileserver, avoiding kernel/userspace copies. 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 e3d817fd7010 https://go.googlecode.com/hg/ #

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

Total comments: 1

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

Patch Set 5 : diff -r e3d817fd7010 https://go.googlecode.com/hg #

Total comments: 3

Patch Set 6 : diff -r e3d817fd7010 https://go.googlecode.com/hg #

Patch Set 7 : diff -r e3d817fd7010 https://go.googlecode.com/hg #

Patch Set 8 : diff -r e3d817fd7010 https://go.googlecode.com/hg #

Patch Set 9 : diff -r e3d817fd7010 https://go.googlecode.com/hg #

Total comments: 9

Patch Set 10 : diff -r e3d817fd7010 https://go.googlecode.com/hg #

Total comments: 7

Patch Set 11 : diff -r 61ff14985684 https://go.googlecode.com/hg/ #

Total comments: 9

Patch Set 12 : diff -r 61ff14985684 https://go.googlecode.com/hg/ #

Total comments: 3

Patch Set 13 : diff -r 61ff14985684 https://go.googlecode.com/hg/ #

Patch Set 14 : diff -r 61ff14985684 https://go.googlecode.com/hg/ #

Total comments: 3

Patch Set 15 : diff -r 61ff14985684 https://go.googlecode.com/hg/ #

Patch Set 16 : diff -r 61ff14985684 https://go.googlecode.com/hg/ #

Patch Set 17 : diff -r 61ff14985684 https://go.googlecode.com/hg/ #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+172 lines, -21 lines) Patch
M src/pkg/http/server.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +21 lines, -0 lines 2 comments Download
M src/pkg/io/io.go View 1 2 3 4 5 1 chunk +14 lines, -10 lines 0 comments Download
M src/pkg/net/Makefile View 1 4 5 3 chunks +18 lines, -11 lines 0 comments Download
A src/pkg/net/sendfile_linux.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +84 lines, -0 lines 0 comments Download
A src/pkg/net/sendfile_stub.go View 1 2 3 4 5 6 7 1 chunk +14 lines, -0 lines 0 comments Download
M src/pkg/net/sock.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +12 lines, -0 lines 0 comments Download
M src/pkg/net/tcpsock.go View 1 2 3 4 5 2 chunks +9 lines, -0 lines 0 comments Download

Messages

Total messages: 49
bradfitz
Hello [email protected] (cc: [email protected]), I'd like you to review this change to https://go.googlecode.com/hg/
14 years, 2 months ago (2011-05-24 17:17:19 UTC) #1
rsc1
I like this version better than any I've seen yet. I think the two errors ...
14 years, 2 months ago (2011-05-24 17:26:07 UTC) #2
bradfitz
On Tue, May 24, 2011 at 10:25 AM, Russ Cox <[email protected]> wrote: > I like ...
14 years, 2 months ago (2011-05-24 17:33:18 UTC) #3
rsc1
> Why not? What if we're chunking? What if compression headers are set? We > ...
14 years, 2 months ago (2011-05-24 17:35:34 UTC) #4
bradfitz
On Tue, May 24, 2011 at 10:35 AM, Russ Cox <[email protected]> wrote: > > Why ...
14 years, 2 months ago (2011-05-24 17:57:17 UTC) #5
bradfitz
On Tue, May 24, 2011 at 10:57 AM, Brad Fitzpatrick <[email protected]>wrote: > On Tue, May ...
14 years, 2 months ago (2011-05-24 17:57:51 UTC) #6
iant2
Russ Cox <[email protected]> writes: > I like this version better than any I've seen yet. ...
14 years, 2 months ago (2011-05-24 17:59:32 UTC) #7
rsc1
> What makes me uncomfortable about ErrUnimplemented is that it means that > anybody who ...
14 years, 2 months ago (2011-05-24 18:01:27 UTC) #8
rsc1
> Do you want: > type LimitedReader interface { > io.Reader > MaxBytesRemaining() int64 > ...
14 years, 2 months ago (2011-05-24 18:02:41 UTC) #9
bradfitzgoog
On Tue, May 24, 2011 at 11:01 AM, Russ Cox <[email protected]> wrote: > > What ...
14 years, 2 months ago (2011-05-24 18:04:25 UTC) #10
gburd
http://codereview.appspot.com/4543071/diff/4001/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4543071/diff/4001/src/pkg/http/server.go#newcode122 src/pkg/http/server.go:122: func (r *response) ReadFrom(src io.Reader) (int64, os.Error) { Here's ...
14 years, 2 months ago (2011-05-24 18:33:18 UTC) #11
bradfitzgoog
On Tue, May 24, 2011 at 11:33 AM, <[email protected]> wrote: > > http://codereview.appspot.com/4543071/diff/4001/src/pkg/http/server.go > File ...
14 years, 2 months ago (2011-05-24 19:16:19 UTC) #12
rsc1
> type writerOnly struct { io.Writer } > > Call io.Copy with a writerOnly instead ...
14 years, 2 months ago (2011-05-24 19:19:36 UTC) #13
bradfitz
Hello [email protected], [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-24 19:51:26 UTC) #14
bradfitz
Now with public io.LimitedReader and Gary's onlyWriter suggestion to remove need for ErrDeclined or io.BufferedCopy. ...
14 years, 2 months ago (2011-05-24 19:52:43 UTC) #15
rsc
I think this is converging on something nice and clean. Detailed comments only on http ...
14 years, 2 months ago (2011-05-24 20:08:54 UTC) #16
bradfitz
Hello [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-24 21:48:34 UTC) #17
bradfitz
PTAL all.bash succeeds on both Linux/amd64 and Darwin/amd64. Trying Linux/386 now.
14 years, 2 months ago (2011-05-24 21:56:01 UTC) #18
bradfitz
On Tue, May 24, 2011 at 2:56 PM, <[email protected]> wrote: > PTAL > > all.bash ...
14 years, 2 months ago (2011-05-24 22:15:48 UTC) #19
rsc
>> all.bash succeeds on both Linux/amd64 and Darwin/amd64. >> >> Trying Linux/386 now. > > ...
14 years, 2 months ago (2011-05-24 22:22:01 UTC) #20
bradfitzgoog
On Tue, May 24, 2011 at 3:21 PM, Russ Cox <[email protected]> wrote: > >> all.bash ...
14 years, 2 months ago (2011-05-24 22:28:24 UTC) #21
bradfitz
On Tue, May 24, 2011 at 3:28 PM, Brad Fitzpatrick <[email protected]>wrote: > On Tue, May ...
14 years, 2 months ago (2011-05-24 22:51:56 UTC) #22
iant
FYI http://codereview.appspot.com/4543071/diff/3009/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): http://codereview.appspot.com/4543071/diff/3009/src/pkg/net/sendfile_linux.go#newcode46 src/pkg/net/sendfile_linux.go:46: if toCopy <= 0 { Seems like this ...
14 years, 2 months ago (2011-05-24 22:53:28 UTC) #23
bradfitz
http://codereview.appspot.com/4543071/diff/3009/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): http://codereview.appspot.com/4543071/diff/3009/src/pkg/net/sendfile_linux.go#newcode46 src/pkg/net/sendfile_linux.go:46: if toCopy <= 0 { On 2011/05/24 22:53:28, iant ...
14 years, 2 months ago (2011-05-24 22:57:13 UTC) #24
bradfitz
Hello [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-24 22:57:29 UTC) #25
rsc
http://codereview.appspot.com/4543071/diff/3009/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): http://codereview.appspot.com/4543071/diff/3009/src/pkg/net/sendfile_linux.go#newcode31 src/pkg/net/sendfile_linux.go:31: osf, ok := r.(*os.File) s/osf/f/ http://codereview.appspot.com/4543071/diff/3009/src/pkg/net/sendfile_linux.go#newcode36 src/pkg/net/sendfile_linux.go:36: destfd := ...
14 years, 2 months ago (2011-05-25 03:42:42 UTC) #26
rsc
http://codereview.appspot.com/4543071/diff/5016/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4543071/diff/5016/src/pkg/http/server.go#newcode127 src/pkg/http/server.go:127: r.Flush() only needed before call to rf.ReadFrom http://codereview.appspot.com/4543071/diff/5016/src/pkg/net/sendfile_linux.go File ...
14 years, 2 months ago (2011-05-25 03:54:26 UTC) #27
rsc
> This loop confuses me. Here's something simpler. > Maybe it's not right but it ...
14 years, 2 months ago (2011-05-25 03:55:37 UTC) #28
bradfitz
Hello [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-25 16:10:53 UTC) #29
bradfitz
http://codereview.appspot.com/4543071/diff/5016/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4543071/diff/5016/src/pkg/http/server.go#newcode127 src/pkg/http/server.go:127: r.Flush() On 2011/05/25 03:54:26, rsc wrote: > only needed ...
14 years, 2 months ago (2011-05-25 16:13:50 UTC) #30
rsc
looks good but can still be a little simpler i think http://codereview.appspot.com/4543071/diff/7010/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): ...
14 years, 2 months ago (2011-05-25 16:24:02 UTC) #31
bradfitz
Hello [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-25 16:45:36 UTC) #32
bradfitz
Simpler! http://codereview.appspot.com/4543071/diff/7010/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): http://codereview.appspot.com/4543071/diff/7010/src/pkg/net/sendfile_linux.go#newcode40 src/pkg/net/sendfile_linux.go:40: for remain != 0 { On 2011/05/25 16:24:02, ...
14 years, 2 months ago (2011-05-25 16:45:54 UTC) #33
rsc
http://codereview.appspot.com/4543071/diff/15003/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): http://codereview.appspot.com/4543071/diff/15003/src/pkg/net/sendfile_linux.go#newcode64 src/pkg/net/sendfile_linux.go:64: return written, err, written > 0 if lr != ...
14 years, 2 months ago (2011-05-25 16:46:34 UTC) #34
bradfitz
http://codereview.appspot.com/4543071/diff/15003/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): http://codereview.appspot.com/4543071/diff/15003/src/pkg/net/sendfile_linux.go#newcode64 src/pkg/net/sendfile_linux.go:64: return written, err, written > 0 On 2011/05/25 16:46:34, ...
14 years, 2 months ago (2011-05-25 16:48:11 UTC) #35
rsc
http://codereview.appspot.com/4543071/diff/15003/src/pkg/net/sendfile_linux.go File src/pkg/net/sendfile_linux.go (right): http://codereview.appspot.com/4543071/diff/15003/src/pkg/net/sendfile_linux.go#newcode52 src/pkg/net/sendfile_linux.go:52: if errno == syscall.EAGAIN { now that the code ...
14 years, 2 months ago (2011-05-25 16:48:23 UTC) #36
bradfitz
Hello [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-25 16:48:52 UTC) #37
bradfitz
Hello [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-25 16:58:18 UTC) #38
bradfitz
Hello [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-25 17:03:06 UTC) #39
rsc
add unixsock.go? http://codereview.appspot.com/4543071/diff/13006/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4543071/diff/13006/src/pkg/http/server.go#newcode134 src/pkg/http/server.go:134: if err == nil { drop if ...
14 years, 2 months ago (2011-05-25 17:03:45 UTC) #40
bradfitz
On Wed, May 25, 2011 at 10:03 AM, <[email protected]> wrote: > add unixsock.go? > UnixSock ...
14 years, 2 months ago (2011-05-25 17:07:27 UTC) #41
bradfitz
Hello [email protected], [email protected], [email protected], [email protected] (cc: [email protected]), Please take another look.
14 years, 2 months ago (2011-05-25 17:08:38 UTC) #42
rsc
> UnixSock has the previously-discussed problem where ReadFrom is already used > by a different ...
14 years, 2 months ago (2011-05-25 17:08:42 UTC) #43
rsc
LGTM++ Turned out very nice.
14 years, 2 months ago (2011-05-25 17:10:46 UTC) #44
bradfitz
*** Submitted as http://code.google.com/p/go/source/detail?r=535caa895f21 *** io, net, http: sendfile support Speeds up static fileserver, avoiding ...
14 years, 2 months ago (2011-05-25 17:15:34 UTC) #45
gburd
http://codereview.appspot.com/4543071/diff/21002/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4543071/diff/21002/src/pkg/http/server.go#newcode140 src/pkg/http/server.go:140: return io.Copy(writerOnly{r}, src) Should r.written be updated here? n, ...
14 years, 2 months ago (2011-05-25 19:13:25 UTC) #46
bradfitz
http://codereview.appspot.com/4543071/diff/21002/src/pkg/http/server.go File src/pkg/http/server.go (right): http://codereview.appspot.com/4543071/diff/21002/src/pkg/http/server.go#newcode140 src/pkg/http/server.go:140: return io.Copy(writerOnly{r}, src) On 2011/05/25 19:13:25, gburd wrote: > ...
14 years, 2 months ago (2011-05-25 19:14:15 UTC) #47
rsc
> n, err = io.Copy(writerOnly{r}, src) > r.written += n > return Copy will call ...
14 years, 2 months ago (2011-05-25 19:14:18 UTC) #48
bradfitz
14 years, 2 months ago (2011-05-25 19:16:00 UTC) #49
On Wed, May 25, 2011 at 12:14 PM, Russ Cox <[email protected]> wrote:

> > n, err = io.Copy(writerOnly{r}, src)
> > r.written += n
> > return
>
> Copy will call r.Write which will update r.written
>

 oh right.

and that would explain why all the tests pass too.  :)

(the tests were catching failures in early versions before I incremented
r.written in the sendfile case...)
Sign in to reply to this message.

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