diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2014-09-18 10:13:15 -0700 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-09-18 10:13:15 -0700 |
| commit | dfd4123edc1863a5b3b6d7cfabba6856c319ba5b (patch) | |
| tree | bce4de52f07170073b1f757b4e41720d13e03fc0 /src/encoding/gob/encoder.go | |
| parent | 73a82db1c8eec314700e2d0f92074a901fa112ed (diff) | |
| download | go-dfd4123edc1863a5b3b6d7cfabba6856c319ba5b.tar.xz | |
encoding/gob: speedup encoding
Replace typeLock with copy-on-write map using atomic.Value.
benchmark old ns/op new ns/op delta
BenchmarkEndToEndPipe 7722 7709 -0.17%
BenchmarkEndToEndPipe-2 5114 4344 -15.06%
BenchmarkEndToEndPipe-4 3192 2429 -23.90%
BenchmarkEndToEndPipe-8 1833 1438 -21.55%
BenchmarkEndToEndPipe-16 1332 983 -26.20%
BenchmarkEndToEndPipe-32 1444 675 -53.25%
BenchmarkEndToEndByteBuffer 6474 6019 -7.03%
BenchmarkEndToEndByteBuffer-2 4280 2810 -34.35%
BenchmarkEndToEndByteBuffer-4 2264 1774 -21.64%
BenchmarkEndToEndByteBuffer-8 1275 979 -23.22%
BenchmarkEndToEndByteBuffer-16 1257 753 -40.10%
BenchmarkEndToEndByteBuffer-32 1342 644 -52.01%
BenchmarkEndToEndArrayByteBuffer 727725 671349 -7.75%
BenchmarkEndToEndArrayByteBuffer-2 394079 320473 -18.68%
BenchmarkEndToEndArrayByteBuffer-4 211785 178175 -15.87%
BenchmarkEndToEndArrayByteBuffer-8 141003 118857 -15.71%
BenchmarkEndToEndArrayByteBuffer-16 139249 86367 -37.98%
BenchmarkEndToEndArrayByteBuffer-32 144128 73454 -49.04%
LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/147720043
Diffstat (limited to 'src/encoding/gob/encoder.go')
| -rw-r--r-- | src/encoding/gob/encoder.go | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/src/encoding/gob/encoder.go b/src/encoding/gob/encoder.go index a3301c3bd3..4b5dc16c79 100644 --- a/src/encoding/gob/encoder.go +++ b/src/encoding/gob/encoder.go @@ -88,9 +88,7 @@ func (enc *Encoder) sendActualType(w io.Writer, state *encoderState, ut *userTyp if _, alreadySent := enc.sent[actual]; alreadySent { return false } - typeLock.Lock() info, err := getTypeInfo(ut) - typeLock.Unlock() if err != nil { enc.setError(err) return @@ -191,9 +189,7 @@ func (enc *Encoder) sendTypeDescriptor(w io.Writer, state *encoderState, ut *use // a singleton basic type (int, []byte etc.) at top level. We don't // need to send the type info but we do need to update enc.sent. if !sent { - typeLock.Lock() info, err := getTypeInfo(ut) - typeLock.Unlock() if err != nil { enc.setError(err) return |
