Age | Commit message (Collapse) | Author |
|
The reflect.Value.Slice method unfortunately allocates every time
since it needs to place the slice header on the heap.
This is silly since gob immediately stores the result back into slice.
Instead, use the reflect.Value.SetLen method.
DecodeBytesSlice 75.0µs ± 2% 35.2µs ± 6% -53.02%
Change-Id: I3ca0529d01bf978f2b76e215f52d369f458951ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/345572
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
|
|
As found by unparam. Picked the low-hanging fruit, consisting only of
errors that were always nil and results that were never used. Left out
those that were useful for consistency with other func signatures.
Change-Id: I06b52bbd3541f8a5d66659c909bd93cb3e172018
Reviewed-on: https://go-review.googlesource.com/102418
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
|
Fixes #23328
Change-Id: Ie4864d7f388d363860318fe41431d8a9719e9a75
Reviewed-on: https://go-review.googlesource.com/86075
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
|
Instead of allocating a new reflect.Value object on every loop we zero it.
DecodeComplex128Slice-8 13.1µs ± 7% 13.2µs ± 8% ~ (p=0.347 n=18+19)
DecodeFloat64Slice-8 8.13µs ± 5% 8.00µs ± 3% ~ (p=0.168 n=20+19)
DecodeInt32Slice-8 8.27µs ± 5% 8.08µs ± 5% -2.27% (p=0.001 n=19+18)
DecodeStringSlice-8 17.9µs ±12% 17.8µs ±11% ~ (p=0.989 n=20+19)
DecodeInterfaceSlice-8 163µs ±10% 159µs ± 4% ~ (p=0.057 n=19+19)
DecodeMap-8 220µs ± 2% 183µs ± 1% -17.07% (p=0.000 n=19+18)
Updates #19525
Change-Id: I27f8edd4761787f6b9928d34cefa08a34a6e25b2
Reviewed-on: https://go-review.googlesource.com/39203
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
|
This allows to pre-allocate the final size of the hashmap and avoid
re-allocating as we insert entries. Furthermore for the current
implementation of the hashmap it allows avoiding several rounds of
evacuating hashmap entries after each re-allocation.
DecodeComplex128Slice-8 51.9µs ± 1% 51.9µs ± 2% ~ (p=0.797 n=30+29)
DecodeFloat64Slice-8 31.5µs ± 2% 31.6µs ± 2% ~ (p=0.050 n=28+28)
DecodeInt32Slice-8 32.0µs ± 2% 31.9µs ± 3% ~ (p=0.666 n=29+28)
DecodeStringSlice-8 57.7µs ± 2% 57.8µs ± 3% ~ (p=0.780 n=27+30)
DecodeInterfaceSlice-8 498µs ± 2% 495µs ± 2% ~ (p=0.070 n=28+29)
DecodeMap-8 300µs ± 2% 230µs ± 5% -23.31% (p=0.000 n=27+27)
Updates #19525
Change-Id: Ia7233da49f05bae7a86c064d9ecebca966f5f2f7
Reviewed-on: https://go-review.googlesource.com/40113
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
|
This provides a significant speedup for encoding and decoding when
using many CPU cores.
name old time/op new time/op delta
EndToEndPipe 5.26µs ± 2% 5.38µs ± 7% ~ (p=0.121 n=8+7)
EndToEndPipe-6 1.86µs ± 5% 1.80µs ±11% ~ (p=0.442 n=8+8)
EndToEndPipe-48 1.39µs ± 2% 1.41µs ± 4% ~ (p=0.645 n=8+8)
EndToEndByteBuffer 1.54µs ± 5% 1.57µs ± 5% ~ (p=0.130 n=8+8)
EndToEndByteBuffer-6 620ns ± 6% 310ns ± 8% -50.04% (p=0.000 n=8+8)
EndToEndByteBuffer-48 506ns ± 4% 110ns ± 3% -78.22% (p=0.000 n=8+8)
EndToEndSliceByteBuffer 149µs ± 3% 153µs ± 5% +2.80% (p=0.021 n=8+8)
EndToEndSliceByteBuffer-6 103µs ±17% 31µs ±12% -70.06% (p=0.000 n=8+8)
EndToEndSliceByteBuffer-48 93.2µs ± 2% 18.0µs ± 5% -80.66% (p=0.000 n=7+8)
EncodeComplex128Slice 20.6µs ± 5% 20.9µs ± 8% ~ (p=0.959 n=8+8)
EncodeComplex128Slice-6 4.10µs ±10% 3.75µs ± 8% -8.58% (p=0.004 n=8+7)
EncodeComplex128Slice-48 1.14µs ± 2% 0.81µs ± 2% -28.98% (p=0.000 n=8+8)
EncodeFloat64Slice 10.2µs ± 7% 10.1µs ± 6% ~ (p=0.694 n=7+8)
EncodeFloat64Slice-6 2.01µs ± 6% 1.80µs ±11% -10.30% (p=0.004 n=8+8)
EncodeFloat64Slice-48 701ns ± 3% 408ns ± 2% -41.72% (p=0.000 n=8+8)
EncodeInt32Slice 11.8µs ± 7% 11.7µs ± 6% ~ (p=0.463 n=8+7)
EncodeInt32Slice-6 2.32µs ± 4% 2.06µs ± 5% -10.89% (p=0.000 n=8+8)
EncodeInt32Slice-48 731ns ± 2% 445ns ± 2% -39.10% (p=0.000 n=7+8)
EncodeStringSlice 9.13µs ± 9% 9.18µs ± 8% ~ (p=0.798 n=8+8)
EncodeStringSlice-6 1.91µs ± 5% 1.70µs ± 5% -11.07% (p=0.000 n=8+8)
EncodeStringSlice-48 679ns ± 3% 397ns ± 3% -41.50% (p=0.000 n=8+8)
EncodeInterfaceSlice 449µs ±11% 461µs ± 9% ~ (p=0.328 n=8+8)
EncodeInterfaceSlice-6 503µs ± 7% 88µs ± 7% -82.51% (p=0.000 n=7+8)
EncodeInterfaceSlice-48 335µs ± 8% 22µs ± 1% -93.55% (p=0.000 n=8+7)
DecodeComplex128Slice 67.2µs ± 4% 67.0µs ± 6% ~ (p=0.721 n=8+8)
DecodeComplex128Slice-6 22.0µs ± 8% 18.9µs ± 5% -14.44% (p=0.000 n=8+8)
DecodeComplex128Slice-48 46.8µs ± 3% 34.9µs ± 3% -25.48% (p=0.000 n=8+8)
DecodeFloat64Slice 39.4µs ± 4% 40.3µs ± 3% ~ (p=0.105 n=8+8)
DecodeFloat64Slice-6 16.1µs ± 2% 11.2µs ± 7% -30.64% (p=0.001 n=6+7)
DecodeFloat64Slice-48 38.1µs ± 3% 24.0µs ± 7% -37.10% (p=0.000 n=8+8)
DecodeInt32Slice 39.1µs ± 4% 40.1µs ± 5% ~ (p=0.083 n=8+8)
DecodeInt32Slice-6 16.3µs ±21% 10.6µs ± 1% -35.17% (p=0.000 n=8+7)
DecodeInt32Slice-48 36.5µs ± 6% 21.9µs ± 9% -39.89% (p=0.000 n=8+8)
DecodeStringSlice 82.9µs ± 6% 85.5µs ± 5% ~ (p=0.121 n=8+7)
DecodeStringSlice-6 32.4µs ±11% 26.8µs ±16% -17.37% (p=0.000 n=8+8)
DecodeStringSlice-48 76.0µs ± 2% 57.0µs ± 5% -25.02% (p=0.000 n=8+8)
DecodeInterfaceSlice 718µs ± 4% 752µs ± 5% +4.83% (p=0.038 n=8+8)
DecodeInterfaceSlice-6 500µs ± 6% 165µs ± 7% -66.95% (p=0.000 n=7+8)
DecodeInterfaceSlice-48 470µs ± 5% 120µs ± 6% -74.55% (p=0.000 n=8+7)
DecodeMap 3.29ms ± 5% 3.34ms ± 5% ~ (p=0.279 n=8+8)
DecodeMap-6 7.73ms ± 8% 7.53ms ±18% ~ (p=0.779 n=7+8)
DecodeMap-48 7.46ms ± 6% 7.71ms ± 3% ~ (p=0.161 n=8+8)
https://perf.golang.org/search?q=upload:20170426.4
Change-Id: I335874028ef8d7c991051004f8caadd16c92d5cc
Reviewed-on: https://go-review.googlesource.com/41872
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
|
|
The improvementis achieved in encoding/gob/decode.go decodeMap by
allocate keyInstr and elemInstr only once and pass it to
decodeIntoValue, instead of allocating a new instance on every loop
cycle.
name old time/op new time/op delta
DecodeComplex128Slice-8 64.2µs ±10% 62.2µs ± 8% ~ (p=0.686 n=4+4)
DecodeFloat64Slice-8 37.1µs ± 3% 36.5µs ± 5% ~ (p=0.343 n=4+4)
DecodeInt32Slice-8 33.7µs ± 3% 32.7µs ± 4% ~ (p=0.200 n=4+4)
DecodeStringSlice-8 59.7µs ± 5% 57.3µs ± 1% ~ (p=0.114 n=4+4)
DecodeInterfaceSlice-8 543µs ± 7% 497µs ± 3% ~ (p=0.057 n=4+4)
DecodeMap-8 3.78ms ± 8% 2.66ms ± 2% -29.69% (p=0.029 n=4+4)
Updates #19525
Change-Id: Iec5fa4530de76f0a70da5de8a129a567b4aa096e
Reviewed-on: https://go-review.googlesource.com/38317
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
|
By replacing bytes-reversing routines with bits.ReverseBytes64 calls.
name old time/op new time/op delta
EncodeComplex128Slice-4 35.1µs ± 1% 23.2µs ± 2% -33.94% (p=0.000 n=20+20)
EncodeFloat64Slice-4 17.9µs ± 1% 11.0µs ± 1% -38.36% (p=0.000 n=17+18)
name old time/op new time/op delta
DecodeComplex128Slice-4 79.7µs ± 0% 69.9µs ± 1% -12.31% (p=0.000 n=20+20)
DecodeFloat64Slice-4 47.3µs ± 1% 42.2µs ± 1% -10.65% (p=0.000 n=17+17)
Change-Id: I91a6401c6009b5712fca6258dd1e57c6fe68ea64
Reviewed-on: https://go-review.googlesource.com/38352
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
|
Found by github.com/mvdan/unparam.
Change-Id: Ic97f05a2ecb5b17caa36aafe403e2266abea3e0e
Reviewed-on: https://go-review.googlesource.com/37836
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
|
|
On linux/386 compared to tip:
name old time/op new time/op delta
DecodeInterfaceSlice-40 1.23ms ± 1% 1.17ms ± 1% -4.93% (p=0.000 n=9+10)
Recovers about half the performance regression from Go 1.6 on 386.
For #16117.
Change-Id: Ie8676d92a4da3e27ff21b91a98b3e13d16730ba1
Reviewed-on: https://go-review.googlesource.com/24468
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
|
The tree's pretty inconsistent about single space vs double space
after a period in documentation. Make it consistently a single space,
per earlier decisions. This means contributors won't be confused by
misleading precedence.
This CL doesn't use go/doc to parse. It only addresses // comments.
It was generated with:
$ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])')
$ go test go/doc -update
Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7
Reviewed-on: https://go-review.googlesource.com/20022
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Day <djd@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
|
Benchmark results:
benchmark old ns/op new ns/op delta
BenchmarkEndToEndPipe-4 7547 7294 -3.35%
BenchmarkEndToEndByteBuffer-4 5146 5092 -1.05%
BenchmarkEndToEndSliceByteBuffer-4 552779 439768 -20.44%
BenchmarkEncodeComplex128Slice-4 266370 266184 -0.07%
BenchmarkEncodeFloat64Slice-4 111891 110258 -1.46%
BenchmarkEncodeInt32Slice-4 74482 74080 -0.54%
BenchmarkEncodeStringSlice-4 84404 84279 -0.15%
BenchmarkEncodeInterfaceSlice-4 3942925 3045995 -22.75%
BenchmarkDecodeComplex128Slice-4 451837 415282 -8.09%
BenchmarkDecodeFloat64Slice-4 283584 262558 -7.41%
BenchmarkDecodeInt32Slice-4 246571 237383 -3.73%
BenchmarkDecodeStringSlice-4 734210 479625 -34.67%
BenchmarkDecodeInterfaceSlice-4 4778225 4160935 -12.92%
benchmark old allocs new allocs delta
BenchmarkEndToEndPipe-4 3 2 -33.33%
BenchmarkEndToEndByteBuffer-4 3 2 -33.33%
BenchmarkEndToEndSliceByteBuffer-4 1002 402 -59.88%
BenchmarkEncodeComplex128Slice-4 1 1 +0.00%
BenchmarkEncodeFloat64Slice-4 1 1 +0.00%
BenchmarkEncodeInt32Slice-4 1 1 +0.00%
BenchmarkEncodeStringSlice-4 1 1 +0.00%
BenchmarkEncodeInterfaceSlice-4 3001 1 -99.97%
BenchmarkDecodeComplex128Slice-4 188 185 -1.60%
BenchmarkDecodeFloat64Slice-4 188 185 -1.60%
BenchmarkDecodeInt32Slice-4 188 185 -1.60%
BenchmarkDecodeStringSlice-4 2188 1185 -45.84%
BenchmarkDecodeInterfaceSlice-4 6197 4194 -32.32%
benchmark old bytes new bytes delta
BenchmarkEndToEndPipe-4 64 48 -25.00%
BenchmarkEndToEndByteBuffer-4 64 48 -25.00%
BenchmarkEndToEndSliceByteBuffer-4 34551 10554 -69.45%
BenchmarkEncodeComplex128Slice-4 55 55 +0.00%
BenchmarkEncodeFloat64Slice-4 33 33 +0.00%
BenchmarkEncodeInt32Slice-4 32 32 +0.00%
BenchmarkEncodeStringSlice-4 36 36 +0.00%
BenchmarkEncodeInterfaceSlice-4 144555 347 -99.76%
BenchmarkDecodeComplex128Slice-4 28240 28097 -0.51%
BenchmarkDecodeFloat64Slice-4 11840 11697 -1.21%
BenchmarkDecodeInt32Slice-4 10817 10673 -1.33%
BenchmarkDecodeStringSlice-4 56128 39985 -28.76%
BenchmarkDecodeInterfaceSlice-4 132565 100421 -24.25%
Change-Id: Ief7c7706b1f2916486ab7190b81aafbb16b70f1e
Reviewed-on: https://go-review.googlesource.com/13660
Reviewed-by: Russ Cox <rsc@golang.org>
|
|
This is not a functional change. nr is a uint64 and can never be less
than zero, remove the no-op comparison.
Fixes #11279
Change-Id: Iebb36cc8fe97428b503e65d01b5e67d2b2bc7369
Reviewed-on: https://go-review.googlesource.com/13876
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
|
This was a simple oversight: the algorithm to handle recursive types
needed to be applied to the ignore-item case as well.
Fixes #10415.
Change-Id: I39ef31cad680ab8334e141f60d2f8707896785d1
Reviewed-on: https://go-review.googlesource.com/8942
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
|
|
Change-Id: I4e59b5b1702e08d7c6191d0a70fb0a555f3340c8
Reviewed-on: https://go-review.googlesource.com/9061
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
|
|
Also unify the tests where possible to make it easy to add more.
Fixes #10273.
Change-Id: Idfa4f4a5dcaa05974066bafe17bed6cdd2ebedb7
Reviewed-on: https://go-review.googlesource.com/8662
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
|
When decoding an invalid typeId the associated *decEngine was not
removed from decoderMap. If the decoder was run again on the same input
a nil *decEngine was found in the map and assumed to be initialized,
resulting in a panic.
Fixes #9649
Change-Id: I5bb51808362a21c09228c2705a658f073e5b59b3
Reviewed-on: https://go-review.googlesource.com/3509
Reviewed-by: Rob Pike <r@golang.org>
|
|
Fix the other places the slice length was being believed, and refactor
the code to use a single function to unify the check.
Fixes #10273.
Change-Id: Ia62b25203fbe87c95d71a70ebc1db8d202eaa4a4
Reviewed-on: https://go-review.googlesource.com/8511
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
|
Change-Id: I6859bd9c9dba30fc5eeb9bbc1de90af67984944c
Reviewed-on: https://go-review.googlesource.com/8526
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
|
decBuffer.Drop is called using data provided by the user, don't
panic if it's bogus.
Fixes #10272.
Change-Id: I913ae9c3c45cef509f2b8eb02d1efa87fbd52afa
Reviewed-on: https://go-review.googlesource.com/8496
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
|
As we did with encoding, provide a trivial byte reader for
faster decoding. We can also reduce some of the copying
by doing the allocation all at once using a slightly different
interface from byte buffers.
benchmark old ns/op new ns/op delta
BenchmarkEndToEndPipe 13368 12902 -3.49%
BenchmarkEndToEndByteBuffer 5969 5642 -5.48%
BenchmarkEndToEndSliceByteBuffer 479485 470798 -1.81%
BenchmarkEncodeComplex128Slice 92367 92201 -0.18%
BenchmarkEncodeFloat64Slice 39990 38960 -2.58%
BenchmarkEncodeInt32Slice 30510 27938 -8.43%
BenchmarkEncodeStringSlice 33753 33365 -1.15%
BenchmarkDecodeComplex128Slice 232278 196704 -15.32%
BenchmarkDecodeFloat64Slice 150258 128191 -14.69%
BenchmarkDecodeInt32Slice 133806 115748 -13.50%
BenchmarkDecodeStringSlice 335117 300534 -10.32%
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154360049
|
|
Use go generate to write better loops for decoding arrays,
just as we did for encoding. It doesn't help as much,
relatively speaking, but it's still noticeable.
benchmark old ns/op new ns/op delta
BenchmarkDecodeComplex128Slice 202348 184529 -8.81%
BenchmarkDecodeFloat64Slice 135800 120979 -10.91%
BenchmarkDecodeInt32Slice 121200 105149 -13.24%
BenchmarkDecodeStringSlice 288129 278214 -3.44%
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154420044
|
|
LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/146320043
|
|
Fixes #8084.
LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/142710043
|
|
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
|