Commit 30c8564
authored
perf(native): scope node loading in call-edge builder for incremental builds (#976)
* perf(native): scope node loading in call-edge builder for incremental builds
On incremental builds, `build_and_insert_call_edges` was loading every
node in the graph (~13k rows in codegraph itself) just to resolve a
handful of changed files' call sites. The deserialization cost dominates
the actual edge-building work for small edits.
Scope the SQL to only the files being processed plus their resolved
import targets. The import context already knows the resolved target
paths, so we stage them in a temp table and `INNER JOIN` against the
nodes table. Full builds still load every node (there is no smaller
set to work with).
Guarded on `is_incremental && file_symbols.len() < 200` so the scoped
path only kicks in when it actually wins — very large incremental
builds fall through to the full-load path to avoid temp-table overhead.
No behavior change: the scoped set is a strict superset of the nodes
the call-edge builder needs (changed files + their import targets).
Cross-file call resolution still sees every target it could previously.
* fix(native): gate scoped call-edge node loading on codebase size
Mirror the JS `loadNodes` gate in `src/domain/graph/builder/stages/build-edges.ts`:
only scope call-edge node loading when the codebase is large enough
(existing file-node count > 20) and the incremental change set is small
(<= 5 files). Tiny fixtures skip the scoped path entirely — the savings
are negligible at that scale and the scoped set can miss transitively-
required nodes needed for receiver-type resolution, breaking the
incremental-edge-parity tests (e.g. `main -> Calculator.compute`).
Also include `barrel_only_files` in the scoped set to match JS exactly.
Fixes the "new export added" parity regression introduced by #976.
Impact: 1 functions changed, 1 affected
* fix(native): include barrel-ultimate targets in scoped edge-build set
Addresses review feedback on #976:
- greptile P1: relevant_files only included direct import targets. Barrel
re-exports resolve imported_names[].file to the ultimate definition
file 2+ hops away, so that file's nodes were absent from all_nodes and
the A->C call edge was silently dropped. Now we walk the barrel chain
during scoping and add every resolved ultimate file.
- greptile P2: align temp-table usage with the existing _analysis_files
pattern (qualified temp. on all non-CREATE ops) and add a covering
index on _edge_files.file so the INNER JOIN is a lookup.
Impact: 1 functions changed, 1 affected1 parent 725d61d commit 30c8564
1 file changed
Lines changed: 137 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| |||
842 | 842 | | |
843 | 843 | | |
844 | 844 | | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
845 | 857 | | |
846 | 858 | | |
847 | 859 | | |
848 | 860 | | |
| 861 | + | |
849 | 862 | | |
850 | 863 | | |
851 | 864 | | |
852 | | - | |
853 | 865 | | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
858 | 989 | | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | 990 | | |
872 | 991 | | |
873 | 992 | | |
| |||
0 commit comments