Skip to content

perf(api): add compact calculator benchmarks / perf(api):新增计算器精简基准测试响应 - #715

Merged
Oseltamivir merged 2 commits into
masterfrom
agent/compact-benchmark-responses
Aug 10, 2026
Merged

perf(api): add compact calculator benchmarks / perf(api):新增计算器精简基准测试响应#715
Oseltamivir merged 2 commits into
masterfrom
agent/compact-benchmark-responses

Conversation

@Oseltamivir

@Oseltamivir Oseltamivir commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a cached, page-owned view=calculator&sequence=... response to /api/v1/benchmarks.
  • Return only the selected calculator scenario and metric keys used by interpolation; omit per-worker telemetry from this view.
  • Keep the default raw benchmark API response unchanged for inference charts and external consumers.
  • Give each compact sequence its own React Query and Blob cache identity.
  • Document the new backend-for-frontend exception and add projection, API-route, client URL, cache-key, and calculator regression coverage.

Impact

Against the repository's representative benchmark fixture, the uncompressed response is smaller by:

  • 1k/1k: 78.0%
  • 1k/8k: 88.2%
  • 8k/1k: 78.0%

This reduces calculator transfer size, browser JSON parsing, and retained React Query memory without changing the reusable raw API contract.

Validation

  • bun run lint
  • bun run fmt
  • bun run typecheck
  • Focused unit/API/calculator tests: 120 passed
  • Calculator Cypress E2E: 66 passed
  • Full unit suite: 3,236 passed; one unrelated pre-existing timezone-sensitive failure remains in visit-tracking.test.ts (does NOT increment when a new session happens on the same calendar day).

中文说明

  • /api/v1/benchmarks 新增带缓存的页面专用响应:view=calculator&sequence=...
  • 仅返回计算器当前所选场景和插值所需指标,并在该视图中省略逐 worker 遥测数据。
  • 推理图表和外部消费者使用的默认原始基准测试 API 响应保持不变。
  • 不同精简场景分别使用独立的 React Query 与 Blob 缓存标识。
  • 补充后端为前端服务(BFF)例外说明,以及字段投影、API 路由、客户端 URL、缓存键和计算器回归测试。

效果

基于仓库中的代表性基准测试 fixture,未压缩响应体缩小:

  • 1k/1k:78.0%
  • 1k/8k:88.2%
  • 8k/1k:78.0%

该优化可减少计算器的数据传输量、浏览器 JSON 解析开销及 React Query 内存占用,同时不改变可复用的原始 API 契约。

验证

  • bun run lint
  • bun run fmt
  • bun run typecheck
  • 聚焦单元测试、API 测试及计算器测试:120 项通过
  • 计算器 Cypress E2E:66 项通过
  • 完整单元测试:3,236 项通过;visit-tracking.test.ts 中仍有一项与本改动无关、受时区影响的既有失败(does NOT increment when a new session happens on the same calendar day)。

Note

Low Risk
Scoped BFF addition with a separate cache namespace; default benchmarks API and inference chart fetching are untouched, with regression tests on projection, routing, URLs, and cache keys.

Overview
Introduces a page-owned compact response on /api/v1/benchmarks via view=calculator&sequence=..., documented alongside other deliberate BFF exceptions. Valid sequences are 1k/1k, 1k/8k, 8k/1k, and agentic-traces; unknown sequences return 400 before hitting the DB.

The route applies toCalculatorBenchmarkRows: filter to the requested scenario, drop workers, and keep only metric keys the calculator interpolation path uses. Results are cached under a separate benchmarks-calculator blob cache key; the default benchmarks response and inference chart consumers are unchanged.

Client plumbing extends fetchBenchmarks, React Query benchmarkQueryOptions / useBenchmarks (sequence-specific cache keys), and useThroughputData so the calculator requests the compact view per selected sequence instead of full raw rows.

Reviewed by Cursor Bugbot for commit ff367db. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a cached calculator-specific benchmark view that returns only the selected scenario and interpolation metrics. Keep the default raw benchmark response unchanged and cover the API, query cache, projection, and calculator behavior.

中文:新增计算器精简基准测试响应
新增带缓存的计算器专用基准测试视图,仅返回所选场景和插值所需指标。默认原始基准测试响应保持不变,并补充 API、查询缓存、字段投影及计算器行为测试。
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
inferencemax-app Ready Ready Preview Aug 10, 2026 7:40am

Request Review

@Oseltamivir
Oseltamivir marked this pull request as ready for review August 10, 2026 07:39
@Oseltamivir
Oseltamivir requested a review from adibarra as a code owner August 10, 2026 07:39
@Oseltamivir
Oseltamivir merged commit 4501bc6 into master Aug 10, 2026
24 checks passed
@Oseltamivir
Oseltamivir deleted the agent/compact-benchmark-responses branch August 10, 2026 07:42
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