gabriel / musehub public
fix patch task/timing-instrumentation #3 / 5
AI Agent gabriel · 40 days ago · May 10, 2026 · Diff

fix: eliminate 850ms cold-import penalty on first push

Two lazy imports inside enqueue_push_intel (musehub_intel_providers — 2700 lines, and musehub_domain_models) were executing cold on the first push request, blocking the asyncio event loop for ~850ms while Python parsed and executed both modules.

Moved both imports to module level in musehub_jobs.py. Also moved the enqueue_push_intel/enqueue_profile_snapshot import in musehub_wire.py to module level for the same reason.

Also separated enqueue from the main data commit so the SELECT IN check runs against an empty session (no autoflush of staged snapshot/commit rows), and added YIELD LATENCY instrumentation to prove streaming latency was not the cause.

Result: 1.36s → 0.36s warm, 0.45s first-request.

sha256:02c83bb8bd449e68b9c4cc8d34134a22191f3b32ea21202c500ab908becf5c4b sha
sha256:4f0e72fc5b9ef83b3463928a0b766bc320a9f27ff33cca6bfc1c3b54fe6e8800 snapshot

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:02c83bb8bd449e68b9c4cc8d34134a22191f3b32ea21202c500ab908becf5c4b --body "your comment"