workers-profiling
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorkers profiling
Workers 性能分析
Find expensive functions or memory allocations in deployed code and come up with ways to fix them.
找出已部署代码中开销较高的函数或内存分配,并提出相应的修复方案。
Retrieve the docs
查阅文档
Start with the production profiling guide to understand how
Workers and Durable Objects profiling works.
首先阅读生产环境性能分析指南,了解 Workers 和 Durable Objects 的性能分析机制。
Profiling steps
性能分析步骤
- Identify the symptom and affected workload: CPU usage, latency, allocation pressure, or memory growth.
- Confirm the account, Worker, environment, and deployed version with the user.
- For a Durable Object, also confirm its owning Worker, namespace, and instance.
- Choose CPU or heap profiling from the current guide's supported types and meanings.
Where possible, use the CLI to capture profiles. If the user requests , inspect the installed version's command help and schema where available.
cfcfIf isn't available, consider prompting the user whether they would like to install it.
cfThe profiling API will return a pprof file which you can analyze directly, or using appropriate tools like Go's utility.
pprof- 确定症状和受影响的工作负载:CPU 使用量、延迟、内存分配压力或内存增长。
- 与用户确认账户、Worker、环境和已部署版本。
- 对于 Durable Object,还需确认其所属的 Worker、命名空间和实例。
- 根据当前指南支持的类型及其含义,选择 CPU 或堆性能分析。
在可行的情况下,使用 CLI 采集性能分析数据。如果用户要求使用 ,请检查已安装版本的命令帮助和 schema(如果可用)。
cfcf如果无法使用 ,可以考虑询问用户是否希望安装它。
cf性能分析 API 将返回 pprof 文件,可以直接分析该文件,也可以使用 Go 的 等适当工具进行分析。
pprofInspect the evidence
检查证据
- Read the pprof file and analyse it for hotspots
- Map hotspots to functions and source locations when evidence supports it; report missing symbols or source mappings.
- If filenames and function names are pointing at the generated JavaScript, consider suggesting to the user to enable source maps and re-do the profiling.
- 读取 pprof 文件并分析其中的热点
- 在证据支持的情况下,将热点映射到函数和源代码位置;报告缺失的符号或 source map
- 如果文件名和函数名指向生成的 JavaScript,可以建议用户启用 source map 并重新进行性能分析
Optimise
优化
Propose the smallest code change supported by the capture which resolves the issues identified.
根据采集的数据,提出能够解决已识别问题的最小代码改动。
Report findings
报告分析结果
Return a concise report with:
- Evidence for each finding: file, function, source location, and metric with units, where available.
- The smallest actionable change and how to check its effect.
返回一份简明报告,其中包括:
- 每项发现的证据:文件、函数、源代码位置和指标;如适用,请附带单位
- 最小可行改动以及检查其效果的方法