Commit 7cb0d02
authored
Use protobuf Arena for fanout response deserialization (valkey-io#1040)
Using protobuf Arena for GRPC fanout response deserialization
### Problem
`SearchIndexPartitionResponse` is heap-allocated in the gRPC client.
Each response contains N `NeighborEntry` sub-messages, each individually
malloc'd during deserialization and individually freed on destruction.
At large result sets, this creates thousands of malloc/free calls per
query per remote shard.
### Fix
Allocate `SearchIndexPartitionResponse` on a `google::protobuf::Arena`.
All sub-messages use bulk arena allocation and are freed in one shot
when the arena is destroyed.
### Benchmark
3-shard CME cluster, 10K docs, TEXT index, 500 concurrent clients
querying one node (fanout to 2 remote shards).
| Workload | Before | After | Improvement |
|---|---|---|---|
| LIMIT 100 CONTENT | 2,496 req/s | 2,572 req/s | +3% throughput |
| LIMIT 500 CONTENT | 306 req/s | 510 req/s | **+67% throughput, -25%
p50** |
| LIMIT 1000 CONTENT | 88 req/s | 272 req/s | **+209% throughput, -44%
p50** |
| NOCONTENT LIMIT 100 | 2,943 req/s | 6,969 req/s | **+137% throughput,
-65% p50** |
Signed-off-by: Karthik Subbarao <karthikrs2021@gmail.com>1 parent 1b85d1a commit 7cb0d02
1 file changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | | - | |
| 146 | + | |
| 147 | + | |
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
150 | 155 | | |
151 | 156 | | |
152 | 157 | | |
| |||
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
159 | | - | |
| 164 | + | |
160 | 165 | | |
161 | 166 | | |
162 | 167 | | |
163 | 168 | | |
164 | | - | |
| 169 | + | |
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
171 | 176 | | |
172 | | - | |
| 177 | + | |
173 | 178 | | |
174 | 179 | | |
175 | 180 | | |
| |||
0 commit comments