gabriel / musehub public
perf patch main #6 / 34
AI Agent gabriel · 116 days ago · May 10, 2026 · Diff

perf: parallel exists() + single bulk INSERT in wire_push_confirm

Replace N sequential backend.exists() calls with asyncio.gather bounded by Semaphore(64), and N individual pg_insert statements with one bulk INSERT INTO musehub_objects VALUES (...) ON CONFLICT DO NOTHING.

TDD: 5 tests (P1–P5) covering call count, concurrency proof, single- statement assertion, wall-clock threshold, and mixed present/absent batch.

sha256:eb00c0a94f83584a7da747f32ee8ef7bbcbc0a8bfcb7f33ae99a8ffcf05d665c sha
+16 ~1 symbols
sha256:0df8cff6ee0e0ccdc2ae61664bc7130bd7da342b459c9adc3f99acacf949806a snapshot
+16
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 17 symbols
~ tests/test_push_confirm_perf.py .py 16 symbols added
+ _make_objects function function _make_objects L47–55
+ AsyncMock import import AsyncMock L34–34
+ AsyncSession import import AsyncSession L37–37
+ MagicMock import import MagicMock L34–34
+ annotations import import annotations L30–30
+ asyncio import import asyncio L32–32
+ create_repo import import create_repo L40–40
+ fake_id import import fake_id L39–39
+ patch import import patch L34–34
+ pytest import import pytest L36–36
+ time import import time L33–33
+ test_p1_exists_called_once_per_object function async_function test_p1_exists_called_once_per_object L63–87
+ test_p2_exists_calls_are_concurrent function async_function test_p2_exists_calls_are_concurrent L95–124
+ test_p3_bulk_insert_single_statement function async_function test_p3_bulk_insert_single_statement L132–162
+ test_p4_wall_clock_under_threshold function async_function test_p4_wall_clock_under_threshold L170–202
+ test_p5_mixed_batch_absent_skipped function async_function test_p5_mixed_batch_absent_skipped L210–232

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:eb00c0a94f83584a7da747f32ee8ef7bbcbc0a8bfcb7f33ae99a8ffcf05d665c --body "your comment"