Skip to content

Fix/mongo location index#19

Open
rav3n11 wants to merge 2 commits into
mainfrom
fix/mongo-location-index
Open

Fix/mongo location index#19
rav3n11 wants to merge 2 commits into
mainfrom
fix/mongo-location-index

Conversation

@rav3n11

@rav3n11 rav3n11 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

rav3n11 added 2 commits June 17, 2026 16:42
Add structured timing blocks so production requests log where time goes,
not just total fetch_parallel_wall_ms / scoring_thread_pool_ms blobs.

- backend/app/database.py: split get_all_jobs_with_timing into
  filter_build_ms / cursor_create_ms / cursor_first_doc_ms /
  cursor_drain_remaining_ms / python_build_jobs_ms, emitted as a
  "mongo /jobs" log_match_step block. Lets us see whether Mongo cost
  is server-side exec, network transfer, or BSON deserialisation.
- backend/app/services/match_concat_gemini_ce_service.py: instrument
  the v3/v4/v5 engine path with prep_job_vectors_ms / job_mat_build_ms
  / gemini_embed_ms / cosine_shortlist_ms / ce_rerank_ms /
  format_user_recs_ms / engine_total_ms, emitted as an
  "engine concat_gemini_ce" block per call (fires twice per request —
  once for jobs, once for occupations).
- backend/app/services/bm25_scoring/bm25library.py: guard BM25Okapi
  against empty corpora that would otherwise raise ZeroDivisionError
  in rank_bm25._calc_idf. Substitutes a sentinel token in empty docs;
  downstream scoring returns 0 for those docs as before.

Why: prod /match_v4 averages 13s wall-clock with scoring_thread_pool_ms
≈ 7s, but we can't see whether the engine cost is Gemini API, CPU-bound
CrossEncoder rerank, or downstream preference scoring. These blocks make
that visible in Cloud Logging without changing any scoring behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant