MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / resolve_worker

Function resolve_worker

src/pipeline/pass_parallel.c:2931–3181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Tested by

no test coverage detected