openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
285 stars 107 forks source link

ytypes.GetNode consumes more CPU & memory than the deprecated util.GetNode #909

Open wenovus opened 1 year ago

wenovus commented 1 year ago

go test -bench=. -benchmem for commit 8fe9f7a:

goos: linux
goarch: amd64
pkg: github.com/openconfig/ygot/ytypes/schema_tests
cpu: Intel(R) Xeon(R) CPU @ 2.80GHz
BenchmarkInterfaceLeafrefs1-48                 1        7915135643 ns/op        4730326800 B/op 77062596 allocs/op
BenchmarkInterfaceLeafrefs2-48                 1        5572959892 ns/op        3378585712 B/op 53392395 allocs/op
BenchmarkInterfaceLeafrefs3-48                 1        5441648833 ns/op        3404838072 B/op 55683811 allocs/op```

For commit e784a05:

goos: linux
goarch: amd64
pkg: github.com/openconfig/ygot/ytypes/schema_tests
cpu: Intel(R) Xeon(R) CPU @ 2.80GHz
BenchmarkInterfaceLeafrefs1-48                 1        6849021162 ns/op        4332677448 B/op 68270498 allocs/op
BenchmarkInterfaceLeafrefs2-48                 1        5050827027 ns/op        3227386800 B/op 49832383 allocs/op
BenchmarkInterfaceLeafrefs3-48                 1        5014178642 ns/op        3224972784 B/op 51428657 allocs/op

git log:

* 8fe9f7a Deprecate `util.GetNodes` in favour of `ytypes.GetNode` (#852)
* e784a05 (HEAD) Support unmarshalling an atomic `Notification` for ordered lists. (#851)