New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: continue to reduce server CPU and allocations #5195
Comments
See issue #1642 (Set capacity of a slice) and https://golang.org/cl/8179043/ to help ReadRequest. |
Patch attached to reduce some more. I'll send it out, broken up, after Go 1.1. Attachments:
|
Patch to address one of the TODOs under the "Life of a Write" comment, bypassing the chunkWriter in some cases. Profiling didn't show any/much improvement, though. I didn't finish investigating why not. It should show a bit. Attachments:
|
For after Go 1.1: https://golang.org/cl/8478044 (part of issue #5192, but a dependency here) |
Work-in-progress playing during bus rides is at https://golang.org/cl/8543043 Currently at: BenchmarkServerHandlerNoHeader 1000000 10256 ns/op 791 B/op 8 allocs/op |
This issue was updated by revision 0af302f. R=r CC=gobot, golang-dev https://golang.org/cl/8478044 |
This issue was updated by revision d4cbc80. R=nigeltao CC=golang-dev https://golang.org/cl/9432046 |
This issue was updated by revision 27f7427. R=golang-dev, daniel.morsing CC=golang-dev https://golang.org/cl/9492044 |
These are mostly all in now. All that remains is: https://golang.org/cl/9584043 but the extra channel operations end up not being worth the reduced GC time. If a sync.Cache goes in (issue #4720), then 9584043 might be worth it. |
This issue was updated by revision 509a117. R=r CC=gobot, golang-dev https://golang.org/cl/8478044 »»» R=r CC=golang-dev https://golang.org/cl/9462049 |
This is a version of Time.Format that doesn't require allocation. This is an updated version of 0af302f submitted by @bradfitz which was later rolled back. Fixes golang#5192 Updates golang#5195 Change-Id: I4e6255bee1cf3914a6cc8d9d2a881cfeb273c08e Reviewed-on: https://go-review.googlesource.com/1760 Reviewed-by: Rob Pike <r@golang.org>
@bradfitz I was just looking through this issue and decided to re-run your initial test, there was one crash $ git log | head -n 1 && go version
commit c2ef005486fa05cbeddc74c7faac8f6a867703d4
go version devel +c2ef005 Thu Dec 10 04:43:08 2015 +0000 darwin/amd64
$ ./http.test -test.v -test.run=none -test.bench=ServerHandler -test.cpuprofile=prof.cpu -test.benchtime=4s
PASS
BenchmarkServerHandlerTypeLen-4 1000000 5549 ns/op 1858 B/op 17 allocs/op
BenchmarkServerHandlerNoLen-4 1000000 5385 ns/op 1826 B/op 14 allocs/op
BenchmarkServerHandlerNoType-4 1000000 5148 ns/op 1826 B/op 15 allocs/op
BenchmarkServerHandlerNoHeader-4 2000000 4358 ns/op 1041 B/op 9 allocs/op
$
$ # Second run because ./http.test -test.v -test.run=none -test.bench=ServerHandler -test.cpuprofile=prof.cpu -test.benchtime=4s only runs clause with `-test.v -test.run=none -test.bench=ServerHandler`
$ ./http.test -test.cpuprofile=prof.cpu -test.benchtime=4s
--- FAIL: TestTransportConcurrency (0.11s)
transport_test.go:1216: error on req request-465: Get http://127.0.0.1:55568/?echo=request-465: write tcp 127.0.0.1:55825->127.0.0.1:55568: write: socket is not connected
FAIL Otherwise this looks like an improvement OldBenchmarkServerHandlerTypeLen 1000000 11098 ns/op 1878 B/op 19 allocs/op
BenchmarkServerHandlerNoLen 1000000 10249 ns/op 1843 B/op 17 allocs/op
BenchmarkServerHandlerNoType 1000000 10620 ns/op 1844 B/op 17 allocs/op
BenchmarkServerHandlerNoHeader 1000000 8674 ns/op 1051 B/op 12 allocs/op NewBenchmarkServerHandlerTypeLen-4 1000000 5549 ns/op 1858 B/op 17 allocs/op
BenchmarkServerHandlerNoLen-4 1000000 5385 ns/op 1826 B/op 14 allocs/op
BenchmarkServerHandlerNoType-4 1000000 5148 ns/op 1826 B/op 15 allocs/op
BenchmarkServerHandlerNoHeader-4 2000000 4358 ns/op 1041 B/op 9 allocs/op |
@odeke-em, this bug is really old. I think it's probably just time to close it. We can open new specific bugs as needed. |
Roger that, thanks! |
Attachments:
The text was updated successfully, but these errors were encountered: