gabriel / musehub public
dev
AI Agent gabriel · 125 days ago · May 12, 2026 · Diff

bench: add bench_wire.py — MuseWire protocol benchmark for all four verbs

Unified benchmark covering Push / Pull / Fetch / Clone across both transport paths (stream and presign) and the full size matrix (XS → XL).

Key design choices: - Fresh repo per run via create_repo() factory — no state leakage between runs - Pull is incremental: seed half the commits, push the other half, time the delta - Clone and Fetch are identical at the wire level (have=[]) but labelled separately - Two HTTP clients per run: ASGITransport for app endpoints, real httpx for MinIO presigned URLs - FETCH_PRESIGN_OBJECT_THRESHOLD and FETCH_PRESIGN_SIZE_THRESHOLD patched to 0 (force presign) or 999_999 (force stream) via module-level override - Objects prefixed with \x00 to avoid the shebang polyglot-attack check - Gates calibrated against observed local throughput (~2 MB/s MinIO GET, ~1 MB/s stream push, ~90 MB/s presign push)

Baseline results (local MinIO, Apple M-series): XS: all 8 scenarios < 400ms, all gates green S: all 8 scenarios < 420ms, all gates green M: push/stream 2s, presign paths < 1.2s, all gates green L: push/presign 315ms @ 67 MB/s — 60x faster than stream XL: push/presign 1.2s @ 91 MB/s — MinIO GET bottleneck at 2 MB/s for fetches

Usage: python3 tests/bench_wire.py --size xs --verb all --runs 3 python3 tests/bench_wire.py --size m --verb push,fetch --path stream python3 tests/bench_wire.py --size l --path presign --runs 1

sha256:c89da6660d0c4135c290f60a3c82d64d803fc18800255cbd06d3b33978ec851f sha
+86 symbols
sha256:8446ecb071eb2a9d3cc26e5fafa7a580c852e72177ceefc0b528c347b2905593 snapshot
+86
symbols added
0
dead code introduced
Semantic Changes 86 symbols
~ tests/bench_wire.py .py 86 symbols added
+ BenchResult class class BenchResult L135–170
+ __init__ method method __init__ L136–141
+ gate method method gate L163–164
+ gate_pass method method gate_pass L166–170
+ p50 method method p50 L147–148
+ p95 method method p95 L150–155
+ record method method record L143–145
+ throughput_mbs method method throughput_mbs L157–161
+ GATES variable variable GATES L90–131
+ SIZE_MATRIX variable variable SIZE_MATRIX L80–86
+ VERB_FNS variable variable VERB_FNS L665–670
+ _AUTH_CTX variable variable _AUTH_CTX L70–75
+ _DB_URL variable variable _DB_URL L57–60
+ _ENGINE variable variable _ENGINE L67–67
+ _FAIL variable variable _FAIL L599–599
+ _MINIO_BUCKET variable variable _MINIO_BUCKET L62–62
+ _MINIO_ENDPOINT variable variable _MINIO_ENDPOINT L61–61
+ _MINIO_KEY variable variable _MINIO_KEY L63–63
+ _MINIO_REGION variable variable _MINIO_REGION L65–65
+ _MINIO_SECRET variable variable _MINIO_SECRET L64–64
+ _PASS variable variable _PASS L598–598
+ _SESSION_FACTORY variable variable _SESSION_FACTORY L68–68
+ _SKIP variable variable _SKIP L600–600
+ _bundle_bytes function function _bundle_bytes L302–313
+ _c_frame function function _c_frame L276–283
+ _create_repo function async_function _create_repo L317–323
+ _e_frame function function _e_frame L285–288
+ _fetch_bundle function async_function _fetch_bundle L403–449
+ _fw variable variable _fw L53–53
+ _gate_str function function _gate_str L602–608
+ _h_frame function function _h_frame L264–268
+ _make_commits_chain function function _make_commits_chain L205–260
+ _make_objects function function _make_objects L192–203
+ _next_seq function function _next_seq L187–190
+ _o_frame function function _o_frame L270–274
+ _pack function function _pack L174–175
+ _patch_thresholds function function _patch_thresholds L653–661
+ _print_results function function _print_results L610–649
+ _push_presign function async_function _push_presign L353–399
+ _push_stream function async_function _push_stream L327–350
+ _seed_repo function async_function _seed_repo L453–464
+ _seq variable variable _seq L185–185
+ _stream_push_body function function _stream_push_body L290–300
+ _unpack function function _unpack L177–178
+ _wrap function function _wrap L180–181
+ bench_clone function async_function bench_clone L570–594
+ bench_fetch function async_function bench_fetch L495–522
+ bench_pull function async_function bench_pull L525–567
+ bench_push function async_function bench_push L468–492
+ ASGITransport import import ASGITransport L39–39
+ Any import import Any L32–32
+ AsyncClient import import AsyncClient L39–39
+ Base import import Base L45–45
+ MSignContext import import MSignContext L49–49
+ MuseWireFrameWriter import import MuseWireFrameWriter L44–44
+ NullPool import import NullPool L41–41
+ Path import import Path L31–31
+ SFRAME_COMMIT_PACK import import SFRAME_COMMIT_PACK L51–51
+ SFRAME_END import import SFRAME_END L51–51
+ SFRAME_HEADER import import SFRAME_HEADER L51–51
+ SFRAME_OBJECT import import SFRAME_OBJECT L51–51
+ WIRE_CONTENT_TYPE import import WIRE_CONTENT_TYPE L44–44
+ _database import import _database L46–46
+ annotations import import annotations L22–22
+ app import import app L48–48
+ argparse import import argparse L24–24
+ async_sessionmaker import import async_sessionmaker L40–40
+ asyncio import import asyncio L25–25
+ blob_id import import blob_id L43–43
+ create_async_engine import import create_async_engine L40–40
+ get_db import import get_db L45–45
+ hashlib import import hashlib L26–26
+ httpx import import httpx L37–37
+ msgpack import import msgpack L38–38
+ muse_cli_models import import musehub.db.muse_cli_models L47–47
+ now_utc_iso import import now_utc_iso L43–43
+ optional_signed_request import import optional_signed_request L49–49
+ optional_token import import optional_token L50–50
+ os import import os L27–27
+ require_signed_request import import require_signed_request L49–49
+ require_valid_token import import require_valid_token L50–50
+ statistics import import statistics L28–28
+ sys import import sys L29–29
+ time import import time L30–30
+ main function async_function main L745–767
+ run_size function async_function run_size L673–742
← Older Oldest on dev
All commits
Newer → Latest on dev

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