Repository navigation
降低 Worker CPU:日期格式化器按时区缓存 - #295
Merged
Merged
Conversation
线上 wrangler tail 实测:/api/mobile/summary 每次 63–84ms CPU、/ingest 36–42ms(Workers Free 单次 10ms,P99 达 135ms,目前未被掐断)。本地基准:每个时刻约 86µs,几乎全部花在每次调用都 new Intl.DateTimeFormat 上(toOffsetIso 一次还构造两遍)。改为按统计时区缓存一个实例、同一 时刻只拆解一次:每个时刻 86µs → 7µs。新增构造次数守卫(1000 个时刻 ≤ 1 次,修复前 3000 次)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks
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.
为什么
回源(等级 7):Workers Free 单次 CPU 上限 10ms,线上 P50 14.5ms、P90 66ms、P99 135ms,0 报错(暂未被掐断)。
wrangler tail逐请求:/api/mobile/summary63–84ms,/ingest36–42ms。根因与改动
本地基准每个时刻约 86µs,几乎全在每次调用都
new Intl.DateTimeFormat(3.0 前后相当,不是 3.0 引入的退化)。改为按统计时区缓存、同一时刻只拆解一次:86µs → 7µs/时刻(约 12×)。验证(等级 3)
test_signed_release本机缺 cryptography,与本改动无关)。部署后用
wrangler tail复测各接口 CPU。🤖 Generated with Claude Code