Commit 234a1ea
authored
hotpath optimization for AddRecord (#4415)
Small optimization in the AddRecord hotpath:
A quick [10s benchmark
test](https://github.com/PeerDB-io/peerdb/blob/47539dc086d58d190e4a101010b60bc153d3c288/flow/model/cdc_stream_bench_test.go)
shows:
```
BenchmarkAddRecordOld 1549653 767.9 ns/op 1074 B/op 23 allocs/op
BenchmarkAddRecordNew 47112669 25.49 ns/op 0 B/op 0 allocs/op
```
The columns represent number of iterations / average wallclock time per
iteration / average bytes of heap memory allocation per iteration /
average number of distinct heap allocations per operation, respectively.
This is probably not a bottleneck on CDC throughput today as we are much
more likely to be bottlenecked on _processing_ cdc message, but given
this code is in the hot path, removing the heap allocation and GC
introduced here in the common case is still beneficial.1 parent 089a1a4 commit 234a1ea
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| |||
0 commit comments