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

Function resolve_worker

src/pipeline/pass_parallel.c:2914–3163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Tested by

no test coverage detected