]> Cypherpunks repositories - gostls13.git/commit
encoding/json: copy-on-write cacheTypeFields
authorDavid Crawshaw <crawshaw@golang.org>
Sat, 25 Jun 2016 14:23:30 +0000 (10:23 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Mon, 27 Jun 2016 15:08:12 +0000 (15:08 +0000)
commit5f209aba6d903688fd5d801bad3fbb5572c85a02
tree852e4329d20b3f46a6105d591e775655f605029f
parent33fa855e6cfa906e12c624663b1010862bf4df6f
encoding/json: copy-on-write cacheTypeFields

Swtich from a sync.RWMutex to atomic.Value for cacheTypeFields.

On GOARCH=386, this recovers most of the remaining performance
difference from the 1.6 release. Compared with tip on linux/386:

name            old time/op    new time/op    delta
CodeDecoder-40    92.8ms ± 1%    87.7ms ± 1%  -5.50%  (p=0.000 n=10+10)

name            old speed      new speed      delta
CodeDecoder-40  20.9MB/s ± 1%  22.1MB/s ± 1%  +5.83%  (p=0.000 n=10+10)

With more time and care, I believe more of the JSON decoder's work
could be shifted so it is done before decoding, and independent of
the number of bytes processed. Maybe someone could explore that for
Go 1.8.

For #16117.

Change-Id: I049655b2e5b76384a0d5f4b90e3ec7cc8d8c4340
Reviewed-on: https://go-review.googlesource.com/24472
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/encoding/json/encode.go