Repository navigation
fix: stop opening a SQLite connection per raw job in discovery - #16
Open
gurmehakk20 wants to merge 1 commit into
Open
gurmehakk20 wants to merge 1 commit into
gurmehakk20 wants to merge 1 commit into
Conversation
|
@gurmehakk20 is attempting to deploy a commit to the Aditya Sakhale's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
run_job_scout()calledcount_company_active_jobs()andhas_applied_to_title()once per raw job scanned instead of once per unique company/title, and each call opened its own fresh SQLite connection — ~30,000 throwaway connections per discovery cycle at real scale (~14,800 raw jobs/cycle).bulk_company_active_counts()andbulk_applied_titles(), each a single batched query; the loop now does in-memory lookups. Same semantics, same log output.main(not a local-only issue) before fixing.Root cause
See
agent/backend/db/jobs_repository.py(oldcount_company_active_jobs/has_applied_to_title) and the loop inagent/backend/services/job_scout.pythat called them per raw job. A clean local benchmark of just one of the two functions at real scale took 14.55s; the batched version takes 0.001s. Under a live process with Windows/filesystem overhead this compounded into multi-minute stalls per discovery cycle, observed directly while running the agent.Test plan
tests/test_jobs_repository_bulk_lookups.py: correctness vs. old per-item semantics, a regression guard asserting exactly 2 SQLite connections regardless of catalog size, and a scale smoke testpytest -q→ 55 passedruff checkclean on changed/new files