工具调度开销、RAG 检索延迟、模型调用封装成本、HITL 往返分布、流水线编排步骤间耗时。可从全新克隆通过 pytest benches/ 复现,与引擎测试约定相同。
本页测量的是 Python 智能体框架,即编排流水线步骤、调度有作用域的工具调用、管理 RAG 检索、通过 HITL 门控写入操作并封装模型调用的运行器。关于自研 Rust 交易引擎(状态缓存写入 310 ns,完整流水线 14 µs),请参阅 引擎延迟。
下方的延迟数据证明运行器足够精简。以下是使其可安全为真实客户运行智能体的保障。本页测量其中十项;其余是平台的构建方式。
每行是我们测量的一个框架工作单元。状态列显示每项指标的当前进度。数值从 framework-bench.json 中提取,该文件在构建时从 melaya-labs/melaya/benchmarks/framework/results/ 下的开源测试结果生成。尚无发布数值的行显示 进行中,而非占位符。
| 指标 | 状态 | p50 | 测量时间 | 备注与复现 |
|---|---|---|---|---|
tool_dispatch (0-arg)per call | 已测量 | 0.60 µs p95 0.60 · p99 1.10 µs · n=10000 | 2026-06-20 | Runner-side cost of dispatching a zero-arg scoped tool: name lookup, ToolResponse wrap. Excludes the tool's own work + any network. 复现: pytest benches/bench_tool_dispatch.py::test_tool_dispatch_0arg -s |
tool_dispatch (5-arg)per call | 已测量 | 0.70 µs p95 0.70 · p99 0.90 µs · n=10000 | 2026-06-20 | Same path, 5-element input dict, median operator-registered shape. 复现: pytest benches/bench_tool_dispatch.py::test_tool_dispatch_5arg -s |
tool_dispatch (20-arg)per call | 已测量 | 1.00 µs p95 1.10 · p99 1.30 µs · n=10000 | 2026-06-20 | Wide-arg dispatch, long-tail tools like melaya_create_order with all optional risk params filled in. 复现: pytest benches/bench_tool_dispatch.py::test_tool_dispatch_20arg -s |
pipeline_step_transition (linear)per step, 10-step chain | 已测量 | 0.22 µs p95 0.23 · p99 0.24 µs · n=2000 | 2026-06-20 | Time from one pipeline step completing to the next being invoked, in a linear chain. Pure runner overhead (graph walk + variable binding + await). 复现: pytest benches/bench_pipeline_orchestration.py::test_pipeline_linear -s |
pipeline_step_transition (parallel)per step, 10-step fanout | 已测量 | 3.32 µs p95 3.64 · p99 5.88 µs · n=2000 | 2026-06-20 | Same transition cost in a parallel fanout via asyncio.gather. Higher than linear here: at N=10 the gather’s scheduling setup dominates, and it only drops below linear once steps block on real I/O. 复现: pytest benches/bench_pipeline_orchestration.py::test_pipeline_parallel -s |
registry_bootper cold boot · register-only | 已测量 | 4.36 ms p95 5218.80 · p99 6368.90 µs · n=30 | 2026-06-20 | The runtime walks its tool + crew modules at boot. The bench measures the introspect+register step on 250 synthetic tools (production adds Python import-time on top, this number is register-only). 复现: pytest benches/bench_registry_boot.py -s |
rag_retrieve (10k chunks)per query, top-5 | 已测量 | 281.10 µs p95 447.10 · p99 782.10 µs · n=2000 | 2026-06-20 | embed(query) + brute-force kNN + chunk hydration over a 10k-chunk in-memory index. A production ANN index is 1.5-3× faster. 复现: pytest benches/bench_rag_retrieval.py::test_rag_retrieval_10k -s |
rag_retrieve (100k chunks)per query, top-5 | 已测量 | 5.52 ms p95 8450.40 · p99 9662.40 µs · n=2000 | 2026-06-20 | Same path, 10× larger corpus. Brute force is O(N·D) so expect ~10-15× growth in p50 vs the 10k bench. 复现: pytest benches/bench_rag_retrieval.py::test_rag_retrieval_100k -s |
model_wrapper_overheadper LLM turn (network mocked) | 已测量 | 1.60 µs p95 2.00 · p99 2.80 µs · n=1000 | 2026-06-20 | Runner overhead around a model API call: prompt assembly, message-history pack, post-response routing. Provider HTTP boundary mocked to isolate runner cost from network. 复现: pytest benches/bench_model_wrapper_overhead.py -s |
context_assemblyper turn | 已测量 | 1.40 µs p95 1.60 · p99 1.80 µs · n=5000 | 2026-06-20 | Builds the static context block a turn sends the model: system prompt + granted knowledge docs + tool schemas. Distinct from rolling history (model_wrapper) and RAG retrieval. 复现: pytest benches/bench_context_assembly.py -s |
session_memoryper save + load | 已测量 | 53.00 µs p95 76.30 · p99 113.30 µs · n=5000 | 2026-06-20 | Cross-run working-memory persistence: serialize a 50-turn crew memory to the session store and restore it on the next run. In-process store, so no DB latency is included. 复现: pytest benches/bench_session_memory.py::test_session_memory_roundtrip -s |
cost_trackingper model call | 已测量 | 0.40 µs p95 0.40 · p99 0.60 µs · n=10000 | 2026-06-20 | Records one model call's token usage against a price table and updates the running USD total plus per-model breakdown. This is what enables per-tenant billing and spend caps. 复现: pytest benches/bench_cost_tracking.py -s |
tracing_overheadper span | 已测量 | 0.30 µs p95 1.10 · p99 1.40 µs · n=10000 | 2026-06-20 | Per-span observability tax: open an OpenTelemetry-style span, stamp the gen_ai / cost / latency attributes, close, and hand to the exporter. What enabling tracing adds per traced operation. 复现: pytest benches/bench_tracing_overhead.py -s |
crew_orchestrationper 4-persona run | 已测量 | 1.20 µs p95 2.00 · p99 2.10 µs · n=2000 | 2026-06-20 | A 4-persona crew (macro, technical, risk, execution) hands context persona to persona, with the risk persona armed to veto and halt the chain mid-run. Pure orchestration overhead. 复现: pytest benches/bench_crew_orchestration.py -s |
prompt_injection_scanper untrusted input | 已测量 | 17.40 µs p95 26.40 · p99 30.50 µs · n=10000 | 2026-06-20 | The prompt-injection scan run on untrusted content (RAG-retrieved docs, tool outputs) before it reaches the model: weighted pattern match against injection / jailbreak / exfiltration markers, then allow / flag / block. Wired into rag.py and the tool-output postprocess. 复现: pytest benches/bench_prompt_injection.py -s |
hitl_gate_overheadper write attempt | 已测量 | 0.30 µs p95 0.40 · p99 0.40 µs · n=10000 | 2026-06-20 | The synchronous safety checks run before every write is queued for approval: sidecar-state read (a reactive watcher that can halt a run), per-cycle write cap, per-tenant daily quota, running cost cap. The trading-grade-discipline machinery, measured, distinct from the human wait below. 复现: pytest benches/bench_hitl_gate_overhead.py -s |
hitl_approval_round_triphuman-bound | 仅方法论 | method documented | n/a | Time from 'approval requested' to 'approval received', median over real operator sessions. Dominated by human attention; cannot be benched synthetically. Methodology documented; awaiting a 30-day production telemetry cut. 复现: see results/hitl_round_trip/methodology_only.json |
concurrent_agent_executionsplatform limit | 配置 | 50 | - | Configurable per-workspace cap on simultaneous agent runs (default 50); backpressure queues the rest. A deployment config knob, not a measurement. 复现: configured in deployment, not benched |
测试套件是独立的 Python 包。无需克隆 melaya-platform,无需外部服务,无需调用 LLM API,无需外部向量存储。从全新 shell 执行三条命令:
git clone https://github.com/melaya-labs/melaya cd melaya/benchmarks/framework pip install -e . && pytest benches/ -s
现代硬件上总实际耗时不到 5 分钟。每项测试生成 results/<metric>/summary.json + 每次迭代的 CSV 文件。去除宿主机噪声的固定运行器(CPU 绑定、performance governor、Windows 高性能电源计划)位于 scripts/bench.sh / scripts/bench.ps1 / 黄金标准层级的 Docker 镜像。完整方法论见测试套件 README。 README.
参考基线是已测量的 D 级设备(i9-13900H,Python 3.12.4,未固定):工具调度约 0.6-1.0 µs,流水线步骤约 0.22 µs,RAG-10k 检索约 0.28 ms。相同代码在不同硬件上差异 2-5 倍:CPython 版本(3.11+ 内置特化自适应解释器,调度速度约快 30%)、CPU 绑定、调速器和 turbo 余量各自影响结果,因此固定生产服务器核心读数更低,笔记本接电池时则高 2-3 倍。对比你的运行结果时,请使用与此表最匹配的层级。
| 层级 | 硬件 | 配置 | tool_dispatch p50 | pipeline_step p50 | registry_boot | rag_retrieval_10k p50 |
|---|---|---|---|---|---|---|
| A. Production | Xeon Plat 8369B (Ice Lake-SP) | Ubuntu 22.04, pinned core, perf gov, py3.12 | awaiting | awaiting | awaiting | awaiting |
| B. Modern Linux server | Xeon Gold 6438 / EPYC 9354 | Ubuntu 22/24, perf gov, py3.12 | 3-8 µs | 10-25 µs | 1-3 s | 0.5-2 ms |
| C. Apple Silicon | M2 / M3 / M4 MacBook | macOS 14+, arm64, py3.12 | 2-6 µs | 8-20 µs | 0.8-2 s | 0.4-1.5 ms |
| D. Modern desktop * | i9-13900H (Raptor Lake-H) | Win11, py3.12.4, unpinned | 0.6-1.0 µs | 0.22 µs | 4.4 ms | 0.28 ms |
D 级(*)已在 i9-13900H(未固定)上测量,为首次提交。A-C 级仍为估算值,直到有贡献者将 summary.json 打包提交至 results/contributed/<tier-slug>/;每个层级的首次实测提交赢得引用位置。(registry_boot 仅包含注册,不含 Python 导入时间,详见上方指标备注。)
上方层级表中,有数据处显示实测数据,无数据处显示估算值。首位在指定层级运行测试套件并将 summary.json 打包提交至 results/contributed/ 的贡献者,将成为下次发布中该层级的可引用参考。提交格式详见测试套件 results/README.md。 results/README.md.
在拥有 R GB 内存的情况下,运行指定场景,可以同时运行多少条流水线, 按操作系统、部署方式保守估算。这里会分别测量两项内容:流水线(与 LLM 无关:堆、浏览器、Qdrant 索引、缓冲区;推理模型始终是外部 HTTP 服务器,因此其权重永远不在流水线内)和模型服务器(Ollama / LM Studio:权重只加载一次,由所有 N 条流水线共享)。模型权重只有在与流水线同机部署时才计入此机器;当模型运行在独立机器上, 云端、企业版或独立本地机器(模拟器中的切换项), 该项在这里就是 0。
N_max = floor( (RAM × 0.8 − model_weights_once − safety) ÷ peak_per_pipeline )peak_per_pipeline = 运行器堆 + 浏览器 + Qdrant + 缓冲区,不含 LLM 权重。同机本地模型:减去 model_weights_once(一个守护进程服务所有 N 条流水线)。当模型运行在独立机器上(云端、企业版或专用本地机器)时,该项在此为 0。按每条流水线的峰值工作集保守估算;能力边际已测量,非推算。
选择流水线的功能、并发数量以及模型的部署位置。 ● 在 tier-d-i9-13900h-win11 上测量; ○ 估算.
4 条流水线中每条需要约 922 MB(RAG (Qdrant, 10k chunks), web_search · browserless (default));推理模型是独立的共享一次项(5.5 GB, 同机部署)。边际值在 tier-d-i9-13900h-win11 上以工作集 RAM(working_set)测量。 ● 已测量, ○ 估算.
测试套件每个场景隔离一个内存驱动因素。这是一个重量级、按需选用的目标(真实 Chromium / Qdrant / 模型服务器),独立于无依赖的延迟测试套件。状态如实呈现:某行仅在某个硬件层级运行过后才显示数值。
| 场景 | 隔离的内存驱动因素 | 峰值 RSS | 状态 |
|---|---|---|---|
Idle floors0_idle | runner floor + drift / orphan gate | 40 MB 637 commit | 已测量 |
LLM-agnostic baselines1_baseline | orchestration heap, real dispatch path | 40 MB 637 commit | 已测量 |
RAG (Qdrant) 10ks2_rag_qdrant | Qdrant index in-runner; embedder remote | 1254 MB 1925 commit | 已测量 |
RAG 100k + doc ingests2b_rag_100k | doc-extraction transient peak | 2056 MB 2926 commit | 已测量 |
web_search fast paths3a_websearch_fast | curl_cffi TLS, no browser (~0) | 52 MB 647 commit | 已测量 |
web_search stealth rescues3b_websearch_browser | Chromium tree (bimodal) | 610 MB 1064 commit | 已测量 |
aiml HF tools_aiml | in-process torch (the one local model load) | 740 MB 2158 commit | 已测量 |
WSS ingress watchers11_wss | in-runner ring buffers | 45 MB 642 commit | 已测量 |
python_repl code-execs12_coderepl | child interpreter + sci-stack (peak) | 173 MB 2016 commit | 已测量 |
remotion renders13_render | Node + 2nd render-Chromium (peak) | 910 MB 2032 commit | 已测量 |
MCP stdio serverss15_mcp | per-server child process | 92 MB 680 commit | 已测量 |
long-context compactions16_compaction | saw-tooth history; reclaim proof | 42 MB 640 commit | 已测量 |
streaming assemblys17_streaming | SSE / token accumulation | 41 MB 638 commit | 已测量 |
huge tool outputs18_tooloutput | multi-MB transient (peak) | 40 MB 642 commit | 已测量 |
concurrency validations_conc | gates the capacity fit | 140 MB 2534 commit | 已测量 |
在 tier-d-i9-13900h-win11 上测量。峰值 RSS 是 RAM 常驻工作集(真实内存占用数字);下方的次要"提交"行是 Windows private_bytes(提交大小),对于 torch 和科学计算栈等保留大量私有虚拟地址的本机库来说高于真实驻留值。按操作系统分别报告(Linux PSS / Windows 工作集 / macOS phys_footprint),不跨操作系统平均。 在你自己的硬件上复现:
轻量级延迟测试套件不受影响 - pip install -e . && pytest benches/ -s 仍可在几分钟内独立运行;内存测试套件是单独的 [memory] 按需选项。完整设计见 benchmarks/framework。
加入社区