Skip to content

perf(backend): reduce isolated unit test startup and image scan work - #23405

Closed
Git-on-my-level wants to merge 1 commit into
mainfrom
sca-1054-backend-test-throughput
Closed

Git-on-my-level wants to merge 1 commit into
mainfrom
sca-1054-backend-test-throughput

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Reduce backend unit-runner startup and static image-contract work after test-slot contention. Reuse parsed imports for identical source text within one image-contract check, defer pytest-httpserver's fixtures to the one loopback test that uses them, and use a fake clock for mentor silence detection. Each image still stages and resolves its own COPY surface; all existing assertions, isolation, markers, and timing budgets remain intact.

The file-isolated runner now prints BACKEND-UNIT-FILE-WALL <seconds>s <file> including collection/import and shutdown, with one-second precision and no extra timing subprocesses.

Product invariants affected

none

How it was verified

  • Fresh task worktree from origin/main (abfff9df7b), managed Git, make setup, Python 3.11.15 on m1-mac-studio.
  • Targeted backend/test.sh selections via BACKEND_UNIT_TEST_FILE_LIST, at nice 19 through omi-heavy, two pytest workers. Ten slow-file candidates selected from the baseline full CI log were measured before and after.
  • Ten-file targeted selection: 1,100 passed before, 1,102 passed after (two new regression cases). Focused runner, real diarizer loopback, and mentor tests: 9 + 11 + 41 passing.
  • Six interleaved plugin-startup pairs: median 0.216s with pytest-httpserver autoload, 0.188s deferred (28ms/process). This is a startup probe, not a full-suite speedup claim.
  • make preflight: all 33 checks passed. Normal pre-push gate passed, including backend type checking (0 errors) and the four changed test files. No hook bypasses.
  • Full-suite after timing and a complete global top-ten ranking remain pending CI; only targeted tests were run locally. The new per-file wall markers make that CI evidence directly extractable.
  • Baseline full CI: https://github.com/BasedHardware/omi/actions/runs/39956214586 (six unit shard steps 609/713/480/477/630/449s; separate slow guardrails session 547.11s). Local full suite was not run, following the targeted-tests-only constraint.

Tests

Existing assertions are unchanged. Regression cases verify that successive scans observe file creation/deletion, identical sources retain nested/lazy imports, and a complete image cannot mask missing files in another image. Runner probes verify the HTTP-server/Werkzeug import chain stays deferred while asyncio remains active; the real loopback test still runs with upstream fixtures.

UI evidence

UI-Evidence: none -- developer infrastructure only.

Failure-Class: none

Targeted file process wall time (seconds)

The ten candidates with the longest test-node spans in the baseline CI unit logs were rerun locally. This is a candidate ranking, not a claim to have profiled all 2,253 files locally. Per-file timings include pytest startup and shutdown. Same selection/order, two workers, nice 19; single runs are load/cache sensitive.

File (backend/tests/unit/) Before After
test_runtime_image_contracts.py 69.86 49.57
test_cross_service_deploy_contract.py 38.97 39.04
test_sync_v2.py 33.95 28.71
test_listen_speaker_id_failover.py 32.50 32.24
test_firestore_query_shapes.py 30.08 23.67
test_desktop_proxy_lifetime.py 26.11 25.89
test_desktop_transcribe.py 19.48 15.11
test_sync_cloud_tasks.py 17.60 16.94
test_task_intelligence_contract_freeze.py 10.83 10.68
test_pipeline_sim_scenarios.py 8.43 8.20

Aggregate file-process time: 287.80s → 250.05s. This sum is not suite elapsed time.
The dominant image source-closure test call measured 45.88s → 26.50s. A cProfile run identified repeated AST parsing/walking across 19 images; the shared cache retains only import statements and is discarded after each check.

View guided diff Turn on auto-fix

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T13:57:48.904478Z aaec0ca PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level marked this pull request as draft November 4, 2026 07:01
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 4, 2026 07:27

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

View guided diff | Turn on auto-fix | Re-trigger cubic

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Folding batch (2026-11-04): this branch's tip was merged into the survivor PR #24477 (feat/cv1-release-safety), which now carries origin/main plus all sixteen folded branches; pushed as 88c7ec5. Both sides' conflict intents were preserved (main's evolved implementations win where a successor of the same intent had already landed). Closing here so the batch lives on one PR. Reopen if something you need is missing from the survivor.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Hey @Git-on-my-level 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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