Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: optimize memory usage for client.List func
If there is a predicate condition, we should not alloc a very large slice ``` goos: linux goarch: amd64 pkg: github.com/ovn-org/libovsdb/client cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz │ bench.out.main │ bench.out.new │ │ sec/op │ sec/op vs base │ APIList/predicate_returns_none-4 3.419m ± 41% 3.238m ± 1% -5.29% (p=0.001 n=10) APIList/predicate_returns_all-4 67.92m ± 3% 68.95m ± 1% ~ (p=0.123 n=10) APIList/predicate_on_an_arbitrary_condition-4 11.88m ± 2% 12.10m ± 11% ~ (p=0.075 n=10) APIList/predicate_matches_name-4 4.073m ± 4% 5.006m ± 17% +22.91% (p=0.000 n=10) APIList/by_index,_no_predicate-4 32.644µ ± 4% 7.957µ ± 3% -75.62% (p=0.000 n=10) APIListMultiple/multiple_results_one_at_a_time_with_Get-4 6.073m ± 4% 6.021m ± 11% ~ (p=0.853 n=10) APIListMultiple/multiple_results_in_a_batch_with_WhereAny-4 3.014m ± 2% 3.085m ± 19% +2.36% (p=0.002 n=10) geomean 3.521m 2.962m -15.89% │ bench.out.main │ bench.out.new │ │ B/op │ B/op vs base │ APIList/predicate_returns_none-4 908.6Ki ± 0% 828.6Ki ± 0% -8.80% (p=0.000 n=10) APIList/predicate_returns_all-4 14.88Mi ± 0% 14.88Mi ± 0% ~ (p=0.315 n=10) APIList/predicate_on_an_arbitrary_condition-4 2.468Mi ± 0% 2.399Mi ± 0% -2.80% (p=0.000 n=10) APIList/predicate_matches_name-4 910.3Ki ± 0% 830.3Ki ± 0% -8.79% (p=0.000 n=10) APIList/by_index,_no_predicate-4 81.997Ki ± 0% 2.000Ki ± 0% -97.56% (p=0.000 n=10) APIListMultiple/multiple_results_one_at_a_time_with_Get-4 1.439Mi ± 0% 1.439Mi ± 0% ~ (p=0.197 n=10) APIListMultiple/multiple_results_in_a_batch_with_WhereAny-4 712.7Ki ± 0% 712.7Ki ± 0% ~ (p=0.280 n=10) geomean 1.128Mi 659.2Ki -42.93% │ bench.out.main │ bench.out.new │ │ allocs/op │ allocs/op vs base │ APIList/predicate_returns_none-4 20.01k ± 0% 20.01k ± 0% -0.00% (p=0.000 n=10) APIList/predicate_returns_all-4 230.1k ± 0% 230.1k ± 0% +0.00% (p=0.048 n=10) APIList/predicate_on_an_arbitrary_condition-4 43.36k ± 0% 43.36k ± 0% ~ (p=1.000 n=10) APIList/predicate_matches_name-4 20.03k ± 0% 20.03k ± 0% ~ (p=1.000 n=10) ¹ APIList/by_index,_no_predicate-4 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹ APIListMultiple/multiple_results_one_at_a_time_with_Get-4 22.02k ± 0% 22.01k ± 0% ~ (p=0.170 n=10) APIListMultiple/multiple_results_in_a_batch_with_WhereAny-4 11.51k ± 0% 11.51k ± 0% ~ (p=1.000 n=10) ¹ geomean 11.83k 11.83k -0.00% ¹ all samples are equal ``` Signed-off-by: Yan Zhu <hackzhuyan@gmail.com>
- Loading branch information