8000 Seed Search images: a deadline they can meet, and a log of late ones by daoudclarke · Pull Request #638 · mwmbl/mwmbl · GitHub
[go: up one dir, main page]

Skip to content

Seed Search images: a deadline they can meet, and a log of late ones - #638

Merged
daoudclarke merged 1 commit into
mainfrom
seed-images-grace
Nov 11, 2026
Merged

daoudclarke merged 1 commit into
mainfrom
seed-images-grace

Conversation

@daoudclarke
@daoudclarke daoudclarke commented Nov 11, 2026 •
Copy link
Copy Markdown
Contributor

From Claude:

What changed

  • IMAGE_SEARCH_GRACE_SECONDS now comes from the environment and defaults to 1.0s, up from 0.25s.
  • When images miss their deadline, seed_images.finish now attaches a done callback to the still-running selection. When the selection finishes, it logs Late images <outcome>: finished N.NNNs after web ranking, with neither the query nor the images.
  • A test checks that a late selection logs once, with a time between the grace and the selection's delay.

Why

After #631 was deployed, 4 of the 5 images=true test searches the rules let through came back unavailable in production (the fifth finished in time). A check script run against api.mwmbl.org showed it. The logs show all 4 were missed deadlines, exactly 0.25s after web ranking:

WARNING:mwmbl.imagesearch.seed_images:Images missed their deadline
INFO:mwmbl.tinysearchengine.combined_search:Images unavailable: 0 in 1.448s, 0.251s after web ranking

Phase 1 is sequential: the Commons search, then the NSFW request.

Request p50 p95 Source
Commons search, 20 candidates 1.02s 1.87s latency_s of the eval's 1,199 collected queries
NSFW request 0.33s 0.50s #614

So phase 1 needs about 1.35s at p50. Web ranking on a cached Staan answer took 0.6–1.2s in the production logs. The evaluations measured each request on its own, but never phase 1 against web ranking end to end.

1.0s should cover most searches, though not the slowest Commons searches. A search with images can now take up to 1s longer than web search alone. One without images is unaffected: the grace applies only when images=true, and only while phase 1 is still running. The "Late images" line shows how far over the misses are, so the setting can be tuned from real numbers. Setting IMAGE_SEARCH_GRACE_SECONDS in the environment changes it without a deploy.

How verified

  • make check passes.
  • make test passes (1883 passed, 10 skipped). The test was tightened afterwards, and test/test_seed_images.py was re-run on the final code (19 passed).
  • A review subagent covered correctness (the callback on the shielded selection after the wait_for timeout), privacy and style. It found nothing blocking. Fixed:
    • the test polls for the log line rather than relying on a fixed sleep, and checks the logged time;
    • the failure check is now a named local;
    • the settings comment no longer quotes production numbers that would go stale.
  • Its concern that the callback might never run if the event loop were torn down per request doesn't apply here: production runs a long-lived uvicorn worker loop.

Part of #610

🤖 Generated with Claude Code

In production every images=true search missed IMAGE_SEARCH_GRACE_SECONDS: phase 1
runs the Commons search (about 1s) and then the NSFW request in turn, while web
ranking on a cached Staan answer takes 0.6-1.2s, and 0.25s of grace wasn't enough.
Raise the default to 1.0s, read it from the environment so it can be tuned without
a deploy, and log when a search that missed its deadline finished, with neither the
query nor the images, so the setting can be tuned from production.

No functional changes to the crawler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov
codecov Bot commented Nov 11, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@daoudclarke
daoudclarke merged commit d1f122b into main Nov 11, 2026
6 of 7 checks passed
@daoudclarke
daoudclarke deleted the seed-images-grace branch November 11, 2026 14:08
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

0