Repository navigation
[spike] storage-backed index: skip chain rebuild + drop edges map - #44
Conversation
rebuild() luôn clear + re-insert toàn bộ func id vào chain trie dù trie đã persist trong rt_* — chiếm >99% thời gian mở index (đo được: ~11s@5k, ~113s@20k). Mirror version-stamp của name engine cho chain engine: ghi [version|count|sample_func] vào slot 0 của storage chính, reopen đọc stamp là bỏ qua rebuild. Kết quả (reopen 20k symbols, full shape): rebuild TOTAL 113.27s → 0.234s (~485×). chains_map vẫn decode đủ cho callees/flow; trie giữ nguyên phục vụ callers/search_flow. Thêm test hồi quy chain_engine_stamp_survives_reopen.
…ll records self.edges: HashMap<(u64,u64), EdgeMeta> (51k entries @ repo này) là bản sao dữ liệu đã persist trong call records — flow() trước giờ vẫn fallback về record khi miss. Xoá hẳn: - GraphIndex.edges + rebuild_edges() + resolve_arg_ids() (arg_ids không ai đọc) - EdgeMeta struct trong codegraph-core (rt_edges luôn rỗng, chưa từng được ghi) - edges_mem/edge_meta_heap trong memtrack; predicted_edges trong bench mem - rebuild(): bỏ fetch+deserialize all_call_records (~130ms@20k), đếm edge_count thẳng từ chains; flow() lấy condition/effect trực tiếp từ record - build_edges_from_calls -> build_call_indexes (đếm edges, không materialize) stats().edges giữ nguyên (u64 count) nên API/MCP/tests không đổi.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (12)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (95.87%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
==========================================
+ Coverage 77.93% 77.95% +0.01%
==========================================
Files 96 96
Lines 23105 23067 -38
==========================================
- Hits 18007 17981 -26
+ Misses 5098 5086 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will improve performance by ×5.6
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | cold_depth1 |
361.8 ms | 33.5 ms | ×11 |
| ⚡ | cold_depth1 |
60.4 ms | 21.2 ms | ×2.9 |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing spike/storage-backed-symbols (f34b8b9) with main (d569b4c)
* perf(graph): skip chain-engine rebuild on reopen via version stamp rebuild() luôn clear + re-insert toàn bộ func id vào chain trie dù trie đã persist trong rt_* — chiếm >99% thời gian mở index (đo được: ~11s@5k, ~113s@20k). Mirror version-stamp của name engine cho chain engine: ghi [version|count|sample_func] vào slot 0 của storage chính, reopen đọc stamp là bỏ qua rebuild. Kết quả (reopen 20k symbols, full shape): rebuild TOTAL 113.27s → 0.234s (~485×). chains_map vẫn decode đủ cho callees/flow; trie giữ nguyên phục vụ callers/search_flow. Thêm test hồi quy chain_engine_stamp_survives_reopen. * refactor(graph): drop in-memory edges map, read edge metadata from call records self.edges: HashMap<(u64,u64), EdgeMeta> (51k entries @ repo này) là bản sao dữ liệu đã persist trong call records — flow() trước giờ vẫn fallback về record khi miss. Xoá hẳn: - GraphIndex.edges + rebuild_edges() + resolve_arg_ids() (arg_ids không ai đọc) - EdgeMeta struct trong codegraph-core (rt_edges luôn rỗng, chưa từng được ghi) - edges_mem/edge_meta_heap trong memtrack; predicted_edges trong bench mem - rebuild(): bỏ fetch+deserialize all_call_records (~130ms@20k), đếm edge_count thẳng từ chains; flow() lấy condition/effect trực tiếp từ record - build_edges_from_calls -> build_call_indexes (đếm edges, không materialize) stats().edges giữ nguyên (u64 count) nên API/MCP/tests không đổi. * Bump version to v2.2.8 --------- Co-authored-by: Hung Pham <hungpham@MacBook-Pro-cua-Hung.local>
Mục tiêu
Giảm thời gian + RAM của
rebuild()bằng cách tận dụng storage/radix/search đã persist, thay vì dựng lại mọi thứ trong RAM.Đã làm (2 commits)
perf(graph): skip chain-engine rebuild on reopen via version stamp
[version|count|sample_func]ở slot 0 storage chính).chain_engine_stamp_survives_reopen.refactor(graph): drop in-memory edges map
GraphIndex.edges: HashMap<(u64,u64), EdgeMeta>+rebuild_edges()+resolve_arg_ids()(arg_ids/is_recursive không ai đọc).EdgeMetastruct khỏi codegraph-core (rt_edgesluôn rỗng — chưa từng được ghi ở production).flow()đọc condition/effect trực tiếp từ call records (cùng nguồn, chính xác theo position hơn bản last-wins cũ).rebuild()bỏ fetch + deserializeall_call_records; đếmedge_counttừ chains.stats().edgesgiữ nguyên (u64) nên API/MCP/tests không đổi.Cần CI kiểm chứng
sibling_file).Chưa làm (tiếp theo nếu spike này ổn)
symbolsmap vẫn load-all (~45ms + RAM) — cần async-hoá read path, ripple lớn nên để riêng.Summary by CodeRabbit