• Pascal S. de Kloe's avatar
    encoding/json: reduce unmarshal mallocs for unmapped fields · df68afd0
    Pascal S. de Kloe authored
    JSON decoding performs poorly for unmapped and ignored fields. We noticed better
    performance when unmarshalling unused fields. The loss comes mostly from calls
    to scanner.error as described at #17914.
    
    benchmark                 old ns/op     new ns/op     delta
    BenchmarkIssue10335-8     431           408           -5.34%
    BenchmarkUnmapped-8       1744          1314          -24.66%
    
    benchmark                 old allocs     new allocs     delta
    BenchmarkIssue10335-8     4              3              -25.00%
    BenchmarkUnmapped-8       18             4              -77.78%
    
    benchmark                 old bytes     new bytes     delta
    BenchmarkIssue10335-8     320           312           -2.50%
    BenchmarkUnmapped-8       568           344           -39.44%
    
    Fixes #17914, improves #10335
    
    Change-Id: I7d4258a94eb287c0fe49e7334795209b90434cd0
    Reviewed-on: https://go-review.googlesource.com/33276Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    df68afd0
Name
Last commit
Last update
..
testdata Loading commit data...
bench_test.go Loading commit data...
decode.go Loading commit data...
decode_test.go Loading commit data...
encode.go Loading commit data...
encode_test.go Loading commit data...
example_marshaling_test.go Loading commit data...
example_test.go Loading commit data...
fold.go Loading commit data...
fold_test.go Loading commit data...
indent.go Loading commit data...
number_test.go Loading commit data...
scanner.go Loading commit data...
scanner_test.go Loading commit data...
stream.go Loading commit data...
stream_test.go Loading commit data...
tables.go Loading commit data...
tagkey_test.go Loading commit data...
tags.go Loading commit data...
tags_test.go Loading commit data...