| 4098 | } |
| 4099 | |
| 4100 | static void resolve_worker(int worker_id, void *ctx_ptr) { |
| 4101 | resolve_ctx_t *rc = ctx_ptr; |
| 4102 | resolve_worker_state_t *ws = &rc->workers[worker_id]; |
| 4103 | |
| 4104 | cbm_pxc_set_rust_manifest(rc->rust_manifest); |
| 4105 | |
| 4106 | if (!ws->local_edge_buf) { |
| 4107 | ws->local_edge_buf = cbm_gbuf_new_worker(rc->project_name, rc->repo_path, rc->shared_ids); |
| 4108 | } |
| 4109 | |
| 4110 | /* Per-worker service-pattern result cache. The same resolved QN |
| 4111 | * (e.g. "fmt.Errorf", "context.Context.Done") appears in many |
| 4112 | * call edges across many files within a project — caching turns |
| 4113 | * cbm_service_pattern_match's 6 × 30 × strstr scan into one hash |
| 4114 | * lookup after the first miss for each QN. Scoped to the worker's |
| 4115 | * lifetime in the parallel_resolve phase. */ |
| 4116 | cbm_service_pattern_cache_begin(); |
| 4117 | cbm_pxc_thread_scratch_begin(); |
| 4118 | file_node_cache_clear(); |
| 4119 | |
| 4120 | while (SKIP_ONE) { |
| 4121 | int file_idx = |
| 4122 | atomic_fetch_add_explicit(&rc->next_file_idx, SKIP_ONE, memory_order_relaxed); |
| 4123 | if (file_idx >= rc->file_count) { |
| 4124 | break; |
| 4125 | } |
| 4126 | cbm_scale_tick(&rc->scale, file_idx); |
| 4127 | if (atomic_load_explicit(rc->cancelled, memory_order_relaxed)) { |
| 4128 | break; |
| 4129 | } |
| 4130 | |
| 4131 | uint64_t _loop_t0 = extract_now_ns(); |
| 4132 | |
| 4133 | if (ws->loaded) { |
| 4134 | cbm_free_result(ws->loaded); |
| 4135 | ws->loaded = NULL; |
| 4136 | } |
| 4137 | CBMFileResult *result = rc->result_cache[file_idx]; |
| 4138 | if (!result && rc->pctx && rc->pctx->spill && |
| 4139 | cbm_result_spill_has(rc->pctx->spill, file_idx)) { |
| 4140 | result = cbm_result_spill_load(rc->pctx->spill, file_idx); |
| 4141 | ws->loaded = result; |
| 4142 | (void)cbm_pipeline_test_extraction_ok(rc->pctx, rc->files[file_idx].language, result); |
| 4143 | } |
| 4144 | if (!result) { |
| 4145 | atomic_fetch_add_explicit(&rc->time_ns_total_loop, extract_now_ns() - _loop_t0, |
| 4146 | memory_order_relaxed); |
| 4147 | continue; |
| 4148 | } |
| 4149 | if (!cbm_pipeline_test_result_ok(rc->pctx, result)) { |
| 4150 | continue; |
| 4151 | } |
| 4152 | atomic_fetch_add_explicit(&rc->total_files_visited, 1, memory_order_relaxed); |
| 4153 | |
| 4154 | CBMLanguage lang = rc->files[file_idx].language; |
| 4155 | const char *rel = rc->files[file_idx].rel_path; |
| 4156 | |
| 4157 | /* Skip cross-LSP for machine-generated files — they're huge (10k- |
nothing calls this directly
no test coverage detected