Reduce peer result validation cost and isolate benchmark pollers #168

Merged
Collaborator

Serialize peer results directly as CallToolResult while preserving advertised schemas, contract validation and wire shape. Move both benchmark feed pollers into a child process with a ready/go/stop handshake, unchanged polling logic and budgets. Add validation-spy positive controls, JSON/SSE wire-shape guards and ADR observations.

Validation: make check passes with 1,227 tests, 8 skipped and 18 deselected, versus 1,222 passing baseline tests. Peer suites pass 198 tests. The three revalidation cases fail before implementation; all five new cases pass afterwards. Wheel/source builds and subprocess smoke checks pass.

Sandbox cProfile on voyager, Python 3.14.5, 20 calls against the 210k-row store:

Before:
Function | Calls | Cumulative seconds
jsonschema.validate | 40 | 2.346
SDK handler | 60 | 1.186
client result validation | 20 | 1.192

After:
Function | Calls | Cumulative seconds
jsonschema.validate | 20 | 1.302
SDK handler | 60 | 0.011
client result validation | 20 | 1.327

No jsonschema.validate caller remains under the server handler after the change; client validation remains.

I02: three architect runs of uv run python3 scripts/bench_feed.py on host voyager at cd1a119. Every budget passes. Loaded ÷ idle search p95 is 1.04, 1.01 and 1.03 (budget 1.25; 1.92 to 2.33 before). Recorded in ADR 0008 by 63e5d6a.

I02 {"base_commit": "cd1a1192d3e2692ea120c612ff3c30ce26984939", "budgets": {"feed_p99_ms": 250, "health_p99_ms": 100, "rss_growth_mib": 64, "search_p95_idle_ratio": 1.25}, "feed": {"all": {"p50_ms": 47.41, "p95_ms": 68.36, "p99_ms": 70.7}, "single": {"p50_ms": 47.46, "p95_ms": 67.87, "p99_ms": 73.34}}, "feed_codes": {"changes": 126}, "feed_pollers": "child process", "feed_samples": {"all": 63, "single": 63}, "health": {"p50_ms": 1.44, "p95_ms": 4.7, "p99_ms": 5.45}, "health_samples": 223, "host": "voyager", "idle_search": {"p50_ms": 107.7, "p95_ms": 117.3, "p99_ms": 129.94}, "implementation_sha256": "1af282b22e4eb64b068b34055579f2dcfbbc7681a18798c6f781e5749d5584a1", "loaded_search": {"p50_ms": 118.46, "p95_ms": 121.42, "p99_ms": 137.58}, "non_200": 0, "passes": {"feed": true, "health": true, "rss": true, "search": true}, "peak_rss_mib": 141.03, "platform": "macOS-26.7.1-arm64-arm-64bit-Mach-O", "python": "3.14.5", "rows": 210000, "rss_increase_mib": 3.39, "search_samples": 26, "snapshot_leg": "unit 3; not measured"}
I02 {"base_commit": "cd1a1192d3e2692ea120c612ff3c30ce26984939", "budgets": {"feed_p99_ms": 250, "health_p99_ms": 100, "rss_growth_mib": 64, "search_p95_idle_ratio": 1.25}, "feed": {"all": {"p50_ms": 47.96, "p95_ms": 70.05, "p99_ms": 77.05}, "single": {"p50_ms": 47.91, "p95_ms": 68.98, "p99_ms": 77.17}}, "feed_codes": {"changes": 124}, "feed_pollers": "child process", "feed_samples": {"all": 62, "single": 62}, "health": {"p50_ms": 1.46, "p95_ms": 4.96, "p99_ms": 5.98}, "health_samples": 221, "host": "voyager", "idle_search": {"p50_ms": 108.43, "p95_ms": 117.7, "p99_ms": 139.11}, "implementation_sha256": "1af282b22e4eb64b068b34055579f2dcfbbc7681a18798c6f781e5749d5584a1", "loaded_search": {"p50_ms": 116.63, "p95_ms": 119.26, "p99_ms": 136.28}, "non_200": 0, "passes": {"feed": true, "health": true, "rss": true, "search": true}, "peak_rss_mib": 140.98, "platform": "macOS-26.7.1-arm64-arm-64bit-Mach-O", "python": "3.14.5", "rows": 210000, "rss_increase_mib": 3.53, "search_samples": 26, "snapshot_leg": "unit 3; not measured"}
I02 {"base_commit": "cd1a1192d3e2692ea120c612ff3c30ce26984939", "budgets": {"feed_p99_ms": 250, "health_p99_ms": 100, "rss_growth_mib": 64, "search_p95_idle_ratio": 1.25}, "feed": {"all": {"p50_ms": 48.15, "p95_ms": 67.84, "p99_ms": 76.76}, "single": {"p50_ms": 48.08, "p95_ms": 68.42, "p99_ms": 76.83}}, "feed_codes": {"changes": 125}, "feed_pollers": "child process", "feed_samples": {"all": 62, "single": 63}, "health": {"p50_ms": 1.53, "p95_ms": 4.82, "p99_ms": 5.95}, "health_samples": 222, "host": "voyager", "idle_search": {"p50_ms": 103.9, "p95_ms": 116.02, "p99_ms": 121.08}, "implementation_sha256": "1af282b22e4eb64b068b34055579f2dcfbbc7681a18798c6f781e5749d5584a1", "loaded_search": {"p50_ms": 115.42, "p95_ms": 120.01, "p99_ms": 128.67}, "non_200": 0, "passes": {"feed": true, "health": true, "rss": true, "search": true}, "peak_rss_mib": 142.92, "platform": "macOS-26.7.1-arm64-arm-64bit-Mach-O", "python": "3.14.5", "rows": 210000, "rss_increase_mib": 5.17, "search_samples": 27, "snapshot_leg": "unit 3; not measured"}

Closes #167
Co-Authored-By: gpt-6.1-sol noreply@openai.com

Serialize peer results directly as CallToolResult while preserving advertised schemas, contract validation and wire shape. Move both benchmark feed pollers into a child process with a ready/go/stop handshake, unchanged polling logic and budgets. Add validation-spy positive controls, JSON/SSE wire-shape guards and ADR observations. Validation: make check passes with 1,227 tests, 8 skipped and 18 deselected, versus 1,222 passing baseline tests. Peer suites pass 198 tests. The three revalidation cases fail before implementation; all five new cases pass afterwards. Wheel/source builds and subprocess smoke checks pass. Sandbox cProfile on voyager, Python 3.14.5, 20 calls against the 210k-row store: Before: Function | Calls | Cumulative seconds jsonschema.validate | 40 | 2.346 SDK handler | 60 | 1.186 client result validation | 20 | 1.192 After: Function | Calls | Cumulative seconds jsonschema.validate | 20 | 1.302 SDK handler | 60 | 0.011 client result validation | 20 | 1.327 No jsonschema.validate caller remains under the server handler after the change; client validation remains. I02: three architect runs of `uv run python3 scripts/bench_feed.py` on host `voyager` at `cd1a119`. Every budget passes. Loaded ÷ idle search p95 is 1.04, 1.01 and 1.03 (budget 1.25; 1.92 to 2.33 before). Recorded in ADR 0008 by `63e5d6a`. ```text I02 {"base_commit": "cd1a1192d3e2692ea120c612ff3c30ce26984939", "budgets": {"feed_p99_ms": 250, "health_p99_ms": 100, "rss_growth_mib": 64, "search_p95_idle_ratio": 1.25}, "feed": {"all": {"p50_ms": 47.41, "p95_ms": 68.36, "p99_ms": 70.7}, "single": {"p50_ms": 47.46, "p95_ms": 67.87, "p99_ms": 73.34}}, "feed_codes": {"changes": 126}, "feed_pollers": "child process", "feed_samples": {"all": 63, "single": 63}, "health": {"p50_ms": 1.44, "p95_ms": 4.7, "p99_ms": 5.45}, "health_samples": 223, "host": "voyager", "idle_search": {"p50_ms": 107.7, "p95_ms": 117.3, "p99_ms": 129.94}, "implementation_sha256": "1af282b22e4eb64b068b34055579f2dcfbbc7681a18798c6f781e5749d5584a1", "loaded_search": {"p50_ms": 118.46, "p95_ms": 121.42, "p99_ms": 137.58}, "non_200": 0, "passes": {"feed": true, "health": true, "rss": true, "search": true}, "peak_rss_mib": 141.03, "platform": "macOS-26.7.1-arm64-arm-64bit-Mach-O", "python": "3.14.5", "rows": 210000, "rss_increase_mib": 3.39, "search_samples": 26, "snapshot_leg": "unit 3; not measured"} I02 {"base_commit": "cd1a1192d3e2692ea120c612ff3c30ce26984939", "budgets": {"feed_p99_ms": 250, "health_p99_ms": 100, "rss_growth_mib": 64, "search_p95_idle_ratio": 1.25}, "feed": {"all": {"p50_ms": 47.96, "p95_ms": 70.05, "p99_ms": 77.05}, "single": {"p50_ms": 47.91, "p95_ms": 68.98, "p99_ms": 77.17}}, "feed_codes": {"changes": 124}, "feed_pollers": "child process", "feed_samples": {"all": 62, "single": 62}, "health": {"p50_ms": 1.46, "p95_ms": 4.96, "p99_ms": 5.98}, "health_samples": 221, "host": "voyager", "idle_search": {"p50_ms": 108.43, "p95_ms": 117.7, "p99_ms": 139.11}, "implementation_sha256": "1af282b22e4eb64b068b34055579f2dcfbbc7681a18798c6f781e5749d5584a1", "loaded_search": {"p50_ms": 116.63, "p95_ms": 119.26, "p99_ms": 136.28}, "non_200": 0, "passes": {"feed": true, "health": true, "rss": true, "search": true}, "peak_rss_mib": 140.98, "platform": "macOS-26.7.1-arm64-arm-64bit-Mach-O", "python": "3.14.5", "rows": 210000, "rss_increase_mib": 3.53, "search_samples": 26, "snapshot_leg": "unit 3; not measured"} I02 {"base_commit": "cd1a1192d3e2692ea120c612ff3c30ce26984939", "budgets": {"feed_p99_ms": 250, "health_p99_ms": 100, "rss_growth_mib": 64, "search_p95_idle_ratio": 1.25}, "feed": {"all": {"p50_ms": 48.15, "p95_ms": 67.84, "p99_ms": 76.76}, "single": {"p50_ms": 48.08, "p95_ms": 68.42, "p99_ms": 76.83}}, "feed_codes": {"changes": 125}, "feed_pollers": "child process", "feed_samples": {"all": 62, "single": 63}, "health": {"p50_ms": 1.53, "p95_ms": 4.82, "p99_ms": 5.95}, "health_samples": 222, "host": "voyager", "idle_search": {"p50_ms": 103.9, "p95_ms": 116.02, "p99_ms": 121.08}, "implementation_sha256": "1af282b22e4eb64b068b34055579f2dcfbbc7681a18798c6f781e5749d5584a1", "loaded_search": {"p50_ms": 115.42, "p95_ms": 120.01, "p99_ms": 128.67}, "non_200": 0, "passes": {"feed": true, "health": true, "rss": true, "search": true}, "peak_rss_mib": 142.92, "platform": "macOS-26.7.1-arm64-arm-64bit-Mach-O", "python": "3.14.5", "rows": 210000, "rss_increase_mib": 5.17, "search_samples": 27, "snapshot_leg": "unit 3; not measured"} ``` Closes #167 Co-Authored-By: gpt-6.1-sol <noreply@openai.com>
Reduce peer result validation cost and isolate benchmark pollers
Some checks failed
ci/woodpecker/pr/validation Pipeline failed
cd1a1192d3
Serialize peer results directly as CallToolResult while preserving advertised schemas, contract validation and wire shape. Move both benchmark feed pollers into a child process with a ready/go/stop handshake, unchanged polling logic and budgets. Add validation-spy positive controls, JSON/SSE wire-shape guards and ADR observations.

Validation: make check passes with 1,227 tests, 8 skipped and 18 deselected, versus 1,222 passing baseline tests. Peer suites pass 198 tests. The three revalidation cases fail before implementation; all five new cases pass afterwards. Wheel/source builds and subprocess smoke checks pass.

Sandbox cProfile on voyager, Python 3.14.5, 20 calls against the 210k-row store:

Before:
Function | Calls | Cumulative seconds
jsonschema.validate | 40 | 2.346
SDK handler | 60 | 1.186
client result validation | 20 | 1.192

After:
Function | Calls | Cumulative seconds
jsonschema.validate | 20 | 1.302
SDK handler | 60 | 0.011
client result validation | 20 | 1.327

No jsonschema.validate caller remains under the server handler after the change; client validation remains.

I02: pending architect acceptance runs on voyager. The ADR contains a placeholder.

Closes #167
Co-Authored-By: gpt-6.1-sol <noreply@openai.com>
Record the #167 I02 host runs in ADR 0008
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
63e5d6a333
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
svc-agent-writer deleted branch feat/svd-dev-mail-mind-mcp-167-cut-the-per-call-cost-of-mail-a76c553f 2026-11-03 11:45:02 +00:00
Sign in to join this conversation.
No description provided.