perf(api): add compact calculator benchmarks / perf(api):新增计算器精简基准测试响应 - #715
Merged
Conversation
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、查询缓存、字段投影及计算器行为测试。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Oseltamivir
marked this pull request as ready for review
August 10, 2026 07:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
view=calculator&sequence=...response to/api/v1/benchmarks.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 lintbun run fmtbun run typecheckvisit-tracking.test.ts(does NOT increment when a new session happens on the same calendar day).中文说明
/api/v1/benchmarks新增带缓存的页面专用响应:view=calculator&sequence=...。效果
基于仓库中的代表性基准测试 fixture,未压缩响应体缩小:
1k/1k:78.0%1k/8k:88.2%8k/1k:78.0%该优化可减少计算器的数据传输量、浏览器 JSON 解析开销及 React Query 内存占用,同时不改变可复用的原始 API 契约。
验证
bun run lintbun run fmtbun run typecheckvisit-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/benchmarksviaview=calculator&sequence=..., documented alongside other deliberate BFF exceptions. Valid sequences are1k/1k,1k/8k,8k/1k, andagentic-traces; unknown sequences return 400 before hitting the DB.The route applies
toCalculatorBenchmarkRows: filter to the requested scenario, dropworkers, and keep only metric keys the calculator interpolation path uses. Results are cached under a separatebenchmarks-calculatorblob cache key; the default benchmarks response and inference chart consumers are unchanged.Client plumbing extends
fetchBenchmarks, React QuerybenchmarkQueryOptions/useBenchmarks(sequence-specific cache keys), anduseThroughputDataso 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.