Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

v3 decoding can allocate 3-6x memory and take 2-3x long as v2 #520

@liggitt

Description

@liggitt

Using benchcmp and the dense/deep object benchmarks added recently:

git checkout v2
go test . -run None -bench . -benchmem > v2.txt
Benchmark1000KB100Aliases-8                    1        1118968506 ns/op        393118512 B/op   5832427 allocs/op
Benchmark1000KBDeeplyNestedSlices-8            5         228028088 ns/op         4690166 B/op       9069 allocs/op
Benchmark1000KBDeeplyNestedMaps-8              5         229030847 ns/op         4690419 B/op       9073 allocs/op
Benchmark1000KBDeeplyNestedIndents-8         500           2855677 ns/op         2970180 B/op      10083 allocs/op
Benchmark1000KB1000IndentLines-8               3         415356292 ns/op        143718512 B/op   4093516 allocs/op
Benchmark1KBMaps-8                          3000            476491 ns/op          218985 B/op       3126 allocs/op
Benchmark10KBMaps-8                          300           4799206 ns/op         2178156 B/op      30780 allocs/op
Benchmark100KBMaps-8                          30          48915174 ns/op        22002808 B/op     307269 allocs/op
Benchmark1000KBMaps-8                          2         525698256 ns/op        220560592 B/op   3072080 allocs/op
git checkout v3
go test . -run None -bench . -benchmem > v3.txt
Benchmark1000KB100Aliases-8                    1        2090412170 ns/op        1470212864 B/op  6344284 allocs/op
Benchmark1000KBDeeplyNestedSlices-8            5         222505744 ns/op        13930344 B/op       9091 allocs/op
Benchmark1000KBDeeplyNestedMaps-8              5         220789034 ns/op        13930736 B/op       9097 allocs/op
Benchmark1000KBDeeplyNestedIndents-8         200           9294121 ns/op        12260665 B/op      10109 allocs/op
Benchmark1000KB1000IndentLines-8               2         714826480 ns/op        697303904 B/op   4093555 allocs/op
Benchmark1KBMaps-8                          2000            746970 ns/op          649890 B/op       3651 allocs/op
Benchmark10KBMaps-8                          200           9184349 ns/op        11417516 B/op      35923 allocs/op
Benchmark100KBMaps-8                          20         101826019 ns/op        114370504 B/op    358502 allocs/op
Benchmark1000KBMaps-8                          1        1075424573 ns/op        1297663912 B/op  3584123 allocs/op
go get golang.org/x/tools/cmd/benchcmp
benchcmp v2.txt v3.txt
benchmark                                old ns/op      new ns/op      delta
Benchmark1000KB100Aliases-8              1118968506     2090412170     +86.82%
Benchmark1000KBDeeplyNestedSlices-8      228028088      222505744      -2.42%
Benchmark1000KBDeeplyNestedMaps-8        229030847      220789034      -3.60%
Benchmark1000KBDeeplyNestedIndents-8     2855677        9294121        +225.46%
Benchmark1000KB1000IndentLines-8         415356292      714826480      +72.10%
Benchmark1KBMaps-8                       476491         746970         +56.76%
Benchmark10KBMaps-8                      4799206        9184349        +91.37%
Benchmark100KBMaps-8                     48915174       101826019      +108.17%
Benchmark1000KBMaps-8                    525698256      1075424573     +104.57%

benchmark                                old allocs     new allocs     delta
Benchmark1000KB100Aliases-8              5832427        6344284        +8.78%
Benchmark1000KBDeeplyNestedSlices-8      9069           9091           +0.24%
Benchmark1000KBDeeplyNestedMaps-8        9073           9097           +0.26%
Benchmark1000KBDeeplyNestedIndents-8     10083          10109          +0.26%
Benchmark1000KB1000IndentLines-8         4093516        4093555        +0.00%
Benchmark1KBMaps-8                       3126           3651           +16.79%
Benchmark10KBMaps-8                      30780          35923          +16.71%
Benchmark100KBMaps-8                     307269         358502         +16.67%
Benchmark1000KBMaps-8                    3072080        3584123        +16.67%

benchmark                                old bytes     new bytes      delta
Benchmark1000KB100Aliases-8              393118512     1470212864     +273.99%
Benchmark1000KBDeeplyNestedSlices-8      4690166       13930344       +197.01%
Benchmark1000KBDeeplyNestedMaps-8        4690419       13930736       +197.00%
Benchmark1000KBDeeplyNestedIndents-8     2970180       12260665       +312.79%
Benchmark1000KB1000IndentLines-8         143718512     697303904      +385.19%
Benchmark1KBMaps-8                       218985        649890         +196.77%
Benchmark10KBMaps-8                      2178156       11417516       +424.18%
Benchmark100KBMaps-8                     22002808      114370504      +419.80%
Benchmark1000KBMaps-8                    220560592     1297663912     +488.35%

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions