Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(metarepos): reuse mrpb.StorageNodeUncommitReport while changed
This change makes mrpb.StorageNodeUncommitReport is reused when it is replaced with a new one. Previous PR, #446, introduced a pool for mrpb.StorageNodeUncommitReport. However, the old StorageNodeUncommitReport stored to reportContext was not reused, and this PR improves it. To release the StorageNodeUncommitReport registered to reportContext, some methods of reportContext are changed: - (*reportContext).getReport returns a value of StorageNodeUncommitReport rather than a pointer. It makes releasing the StorageNodeUncommitReport happen at any time. - add (*reportContext).swapReport to set a new StorageNodeUncommitReport and get the old one simultaneously. - getReport and swapReport return the boolean result to indicate whether the result report is zero value. BenchmarkSwapReport evaluates the performance improvements of this change. - getAndSavePtr: Previous implementation. - getAndSave: Call getReport and saveReport. - swap: Call swapReport. ``` BenchmarkSwapReport/getAndSavePtr-16 5947423 207.8 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6220454 198.7 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6133489 198.5 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6131910 199.8 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 5592459 201.6 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6180243 200.1 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6172357 199.2 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6211966 198.6 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6095289 198.3 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSavePtr-16 6043491 197.6 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6143407 200.6 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 5938540 203.6 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6162986 198.5 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6172598 197.8 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6105918 197.0 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6077460 196.5 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 5953898 197.8 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6131799 199.9 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6139296 200.5 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/getAndSave-16 6115653 198.5 ns/op 32 B/op 1 allocs/op BenchmarkSwapReport/swap-16 35501544 33.83 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 35982945 34.05 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 36518960 34.21 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 34620783 34.52 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 35967453 33.88 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 36135454 34.17 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 34492548 35.16 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 35581888 34.14 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 32028504 33.78 ns/op 0 B/op 0 allocs/op BenchmarkSwapReport/swap-16 36024037 33.94 ns/op 0 B/op 0 allocs/op ```
- Loading branch information