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

Function resolve_worker

src/pipeline/pass_parallel.c:2593–2837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2591}
2592
2593static void resolve_worker(int worker_id, void *ctx_ptr) {
2594 resolve_ctx_t *rc = ctx_ptr;
2595 resolve_worker_state_t *ws = &rc->workers[worker_id];
2596
2597 if (!ws->local_edge_buf) {
2598 ws->local_edge_buf =
2599 cbm_gbuf_new_shared_ids(rc->project_name, rc->repo_path, rc->shared_ids);
2600 }
2601
2602 /* Per-worker service-pattern result cache. The same resolved QN
2603 * (e.g. "fmt.Errorf", "context.Context.Done") appears in many
2604 * call edges across many files within a project — caching turns
2605 * cbm_service_pattern_match's 6 × 30 × strstr scan into one hash
2606 * lookup after the first miss for each QN. Scoped to the worker's
2607 * lifetime in the parallel_resolve phase. */
2608 cbm_service_pattern_cache_begin();
2609
2610 while (SKIP_ONE) {
2611 int file_idx =
2612 atomic_fetch_add_explicit(&rc->next_file_idx, SKIP_ONE, memory_order_relaxed);
2613 if (file_idx >= rc->file_count) {
2614 break;
2615 }
2616 if (atomic_load_explicit(rc->cancelled, memory_order_relaxed)) {
2617 break;
2618 }
2619
2620 uint64_t _loop_t0 = extract_now_ns();
2621
2622 CBMFileResult *result = rc->result_cache[file_idx];
2623 if (!result) {
2624 atomic_fetch_add_explicit(&rc->time_ns_total_loop, extract_now_ns() - _loop_t0,
2625 memory_order_relaxed);
2626 continue;
2627 }
2628 atomic_fetch_add_explicit(&rc->total_files_visited, 1, memory_order_relaxed);
2629
2630 CBMLanguage lang = rc->files[file_idx].language;
2631 const char *rel = rc->files[file_idx].rel_path;
2632
2633 /* Skip cross-LSP for machine-generated files — they're huge (10k-
2634 * 70k lines for k8s protobuf/openapi), have low semantic value for
2635 * graph navigation (boilerplate getters/setters/marshal), and
2636 * dominate the cross-LSP wall time when they have even one
2637 * unresolved call (tree-sitter parse on a 70k-line file is ~1-2s).
2638 * The per-file LSP during extract still indexes their defs/calls
2639 * normally — only the cross-file resolution refinement is skipped. */
2640 bool is_generated = false;
2641 if (rel) {
2642 is_generated =
2643 (strstr(rel, ".pb.go") != NULL) || (strstr(rel, "zz_generated") != NULL) ||
2644 (strstr(rel, "_generated.go") != NULL) || (strstr(rel, ".gen.go") != NULL) ||
2645 (strstr(rel, "/applyconfigurations/") != NULL) ||
2646 (strstr(rel, "_pb2.py") != NULL) || (strstr(rel, "_pb2_grpc.py") != NULL) ||
2647 (strstr(rel, ".pb.cc") != NULL) || (strstr(rel, ".pb.h") != NULL) ||
2648 (strstr(rel, ".pb-c.c") != NULL) || (strstr(rel, ".pb-c.h") != NULL);
2649 }
2650

Callers

nothing calls this directly

Calls 15

cbm_gbuf_new_shared_idsFunction · 0.85
extract_now_nsFunction · 0.85
cbm_pxc_has_cross_lspFunction · 0.85
pp_module_is_dirFunction · 0.85
cbm_index_mark_startFunction · 0.85
cbm_pxc_dispatch_fileFunction · 0.85
cbm_index_mark_doneFunction · 0.85

Tested by

no test coverage detected