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

Issue 58260043: code review 58260043: net/http: use a struct instead of a string in transport... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 5 months ago by bradfitz
Modified:
11 years, 5 months ago
Reviewers:
adg, dvyukov
CC:
adg, golang-codereviews
Visibility:
Public.

Description

net/http: use a struct instead of a string in transport conn cache key The Transport's idle connection cache is keyed by a string, for pre-Go 1.0 reasons. Ever since Go has been able to use structs as map keys, there's been a TODO in the code to use structs instead of allocating strings. This change does that. Saves 3 allocatins and ~100 bytes of garbage per client request. But because string hashing is so fast these days (thanks, Keith), the performance is a wash: what we gain on GC and not allocating, we lose in slower hashing. (hashing structs of strings is slower than 1 string) This seems a bit faster usually, but I've also seen it be a bit slower. But at least it's how I've wanted it now, and it the allocation improvements are consistent.

Patch Set 1 #

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

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+43 lines, -36 lines) Patch
M src/pkg/net/http/export_test.go View 1 2 chunks +6 lines, -5 lines 0 comments Download
M src/pkg/net/http/proxy_test.go View 1 1 chunk +2 lines, -2 lines 0 comments Download
M src/pkg/net/http/transport.go View 1 2 3 11 chunks +35 lines, -29 lines 0 comments Download

Messages

Total messages: 5
bradfitz
Hello adg (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
11 years, 5 months ago (2014-01-29 12:52:42 UTC) #1
adg
LGMT
11 years, 5 months ago (2014-01-30 07:01:57 UTC) #2
adg
LGTM
11 years, 5 months ago (2014-01-30 08:55:32 UTC) #3
bradfitz
*** Submitted as https://code.google.com/p/go/source/detail?r=22fe13ae3884 *** net/http: use a struct instead of a string in transport ...
11 years, 5 months ago (2014-01-30 08:57:07 UTC) #4
dvyukov
11 years, 5 months ago (2014-01-30 11:27:26 UTC) #5
Message was sent while issue was closed.
FYI

---------- Forwarded message ----------
Date: Thu, Jan 30, 2014 at 3:10 PM
Subject: Perf changes on windows-amd64 by net/http: use a struct instead of a
string in transport conn cache key


Change 22fe13ae3884 caused perf changes on windows-amd64:

net/http: use a struct instead of a string in transport conn cache key

The Transport's idle connection cache is keyed by a string,
for pre-Go 1.0 reasons.  Ever since Go has been able to use
structs as map keys, there's been a TODO in the code to use
structs instead of allocating strings. This change does that.

Saves 3 allocatins and ~100 bytes of garbage per client
request. But because string hashing is so fast these days
(thanks, Keith), the performance is a wash: what we gain
on GC and not

http://code.google.com/p/go/source/detail?r=22fe13ae3884

http-1                    old          new      delta
allocs                     57           54      -5.26

http-8                    old          new      delta
allocs                     72           68      -5.56

http://goperfd.appspot.com/perfdetail?commit=22fe13ae3884ef4349cfb78ad5804ebc...
Sign in to reply to this message.

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