| 2935 | } |
| 2936 | |
| 2937 | static void resolve_worker(int worker_id, void *ctx_ptr) { |
| 2938 | resolve_ctx_t *rc = ctx_ptr; |
| 2939 | resolve_worker_state_t *ws = &rc->workers[worker_id]; |
| 2940 | |
| 2941 | if (!ws->local_edge_buf) { |
| 2942 | ws->local_edge_buf = |
| 2943 | cbm_gbuf_new_shared_ids(rc->project_name, rc->repo_path, rc->shared_ids); |
| 2944 | } |
| 2945 | |
| 2946 | /* Per-worker service-pattern result cache. The same resolved QN |
| 2947 | * (e.g. "fmt.Errorf", "context.Context.Done") appears in many |
| 2948 | * call edges across many files within a project — caching turns |
| 2949 | * cbm_service_pattern_match's 6 × 30 × strstr scan into one hash |
| 2950 | * lookup after the first miss for each QN. Scoped to the worker's |
| 2951 | * lifetime in the parallel_resolve phase. */ |
| 2952 | cbm_service_pattern_cache_begin(); |
| 2953 | |
| 2954 | while (SKIP_ONE) { |
| 2955 | int file_idx = |
| 2956 | atomic_fetch_add_explicit(&rc->next_file_idx, SKIP_ONE, memory_order_relaxed); |
| 2957 | if (file_idx >= rc->file_count) { |
| 2958 | break; |
| 2959 | } |
| 2960 | cbm_scale_tick(&rc->scale, file_idx); |
| 2961 | if (atomic_load_explicit(rc->cancelled, memory_order_relaxed)) { |
| 2962 | break; |
| 2963 | } |
| 2964 | |
| 2965 | uint64_t _loop_t0 = extract_now_ns(); |
| 2966 | |
| 2967 | CBMFileResult *result = rc->result_cache[file_idx]; |
| 2968 | if (!result) { |
| 2969 | atomic_fetch_add_explicit(&rc->time_ns_total_loop, extract_now_ns() - _loop_t0, |
| 2970 | memory_order_relaxed); |
| 2971 | continue; |
| 2972 | } |
| 2973 | atomic_fetch_add_explicit(&rc->total_files_visited, 1, memory_order_relaxed); |
| 2974 | |
| 2975 | CBMLanguage lang = rc->files[file_idx].language; |
| 2976 | const char *rel = rc->files[file_idx].rel_path; |
| 2977 | |
| 2978 | /* Skip cross-LSP for machine-generated files — they're huge (10k- |
| 2979 | * 70k lines for k8s protobuf/openapi), have low semantic value for |
| 2980 | * graph navigation (boilerplate getters/setters/marshal), and |
| 2981 | * dominate the cross-LSP wall time when they have even one |
| 2982 | * unresolved call (tree-sitter parse on a 70k-line file is ~1-2s). |
| 2983 | * The per-file LSP during extract still indexes their defs/calls |
| 2984 | * normally — only the cross-file resolution refinement is skipped. */ |
| 2985 | bool is_generated = false; |
| 2986 | if (rel) { |
| 2987 | is_generated = |
| 2988 | (strstr(rel, ".pb.go") != NULL) || (strstr(rel, "zz_generated") != NULL) || |
| 2989 | (strstr(rel, "_generated.go") != NULL) || (strstr(rel, ".gen.go") != NULL) || |
| 2990 | (strstr(rel, "/applyconfigurations/") != NULL) || |
| 2991 | (strstr(rel, "_pb2.py") != NULL) || (strstr(rel, "_pb2_grpc.py") != NULL) || |
| 2992 | (strstr(rel, ".pb.cc") != NULL) || (strstr(rel, ".pb.h") != NULL) || |
| 2993 | (strstr(rel, ".pb-c.c") != NULL) || (strstr(rel, ".pb-c.h") != NULL); |
| 2994 | } |
nothing calls this directly
no test coverage detected