Commit fea7b5e
authored
* perf(native): batch-load file/symbol node IDs in edges phase (#1013)
Replaces per-import and per-file `conn.query_row` calls in
`build_import_edges` and `build_and_insert_call_edges` with one-shot
HashMap pre-loads. Each `query_row` ran a fresh sqlite3_prepare/step/
finalize cycle; on a ~470-file repo this paid ~2.3k cycles in the
import-edge stage alone, dominating the edges phase.
Also chunks the import-edge insert into multi-row VALUES batches
(199 rows × 5 params), mirroring `edges_db::do_insert_edges`, to
remove the per-row prepared-statement bind/step/reset overhead.
Self-build benchmark (codegraph on itself, 743 files):
edges: 124.5 ms native vs 193 ms wasm (was 310 ms / 179 ms in 3.9.5)
roles: 73.7 ms native vs 70 ms wasm (was 269 ms / 62 ms in 3.9.5)
Roles converged as a side effect — its prior tail was driven by
shared SQLite cache pressure during the same build session.
Closes #1013
(docs check acknowledged: internal perf fix, no API/language/feature surface changes)
* fix(native): bound symbol-node lookup and restore name=file guard (#1028)
Address two P2 review concerns from greptile on #1013:
1. **Bounded symbol-node lookup.** `load_symbol_node_ids` previously did
an unbounded `SELECT name, file, id FROM nodes WHERE kind != 'file'`,
loading every non-file symbol into memory. On 100k+-symbol monorepos
this could push hundreds of MB. Now we walk type-only imports up
front to collect the distinct `(name, file)` pairs we'll actually
need, then issue a chunked `(name, file) IN (...)` query (332 pairs
per chunk × 2 binds = 664, safely under `SQLITE_MAX_VARIABLE_NUMBER`).
The full-scan path is gone; only the symbols referenced by type-only
imports are hit, preserving the one-round-trip win without the
memory blow-up.
2. **Restore `name = file` guard on file-node lookups.** The original
per-row query bound `rel_path` to both `name = ?` and `file = ?`,
matching only nodes where the two columns agreed. The bulk query
keyed on `file` alone, so an unrelated file-kind row sharing the
same `file` value (different `name`) could silently overwrite the
map entry. Add `AND name = file` to both `load_file_node_ids` and
the parallel pre-load in `build_and_insert_call_edges` to keep the
legacy semantics explicit.
* fix(native): surface bind/execute errors in insert_edges (#1028)
Greptile flagged two P2 issues in `insert_edges`:
1. Silent bind failures: `let _ = stmt.raw_bind_parameter(...)` silently
discarded errors. A failed bind would leave that position unbound
(NULL), causing `raw_execute()` to insert ghost edge rows with NULL
`source_id`/`target_id`. Bind/execute now run inside a fallible
`insert_edge_chunk` helper; failures emit a stderr warning and the
chunk is skipped instead of producing partial rows.
2. `prepare_cached` mismatched with dynamic SQL: the SQL string varies
with chunk length, so trailing partial chunks were always cache
misses. Switched to plain `tx.prepare(&sql)` to match intent.
No behavioural change for the success path. cargo test
-p codegraph-core --lib: 181 passed.
1 parent a724a09 commit fea7b5e
2 files changed
Lines changed: 227 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1081 | 1081 | | |
1082 | 1082 | | |
1083 | 1083 | | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
1084 | 1109 | | |
1085 | 1110 | | |
1086 | 1111 | | |
1087 | 1112 | | |
1088 | 1113 | | |
1089 | 1114 | | |
1090 | 1115 | | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
1099 | 1119 | | |
1100 | 1120 | | |
1101 | 1121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
164 | 179 | | |
165 | 180 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
174 | 268 | | |
175 | 269 | | |
176 | 270 | | |
| |||
185 | 279 | | |
186 | 280 | | |
187 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
188 | 296 | | |
189 | 297 | | |
190 | | - | |
191 | | - | |
| 298 | + | |
| 299 | + | |
192 | 300 | | |
193 | 301 | | |
194 | 302 | | |
| |||
203 | 311 | | |
204 | 312 | | |
205 | 313 | | |
206 | | - | |
207 | | - | |
| 314 | + | |
| 315 | + | |
208 | 316 | | |
209 | 317 | | |
210 | 318 | | |
| |||
238 | 346 | | |
239 | 347 | | |
240 | 348 | | |
241 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
242 | 352 | | |
243 | 353 | | |
244 | 354 | | |
| |||
262 | 372 | | |
263 | 373 | | |
264 | 374 | | |
265 | | - | |
| 375 | + | |
266 | 376 | | |
267 | 377 | | |
268 | 378 | | |
| |||
286 | 396 | | |
287 | 397 | | |
288 | 398 | | |
289 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
290 | 412 | | |
291 | 413 | | |
292 | 414 | | |
293 | 415 | | |
294 | 416 | | |
295 | 417 | | |
296 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
297 | 422 | | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
309 | 430 | | |
310 | 431 | | |
311 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
312 | 475 | | |
313 | 476 | | |
314 | 477 | | |
| |||
0 commit comments