跳到正文
Simon Willison·· 5 天前AI 评分20

用 Python 3.15 剖析 web-edit:火焰图与源码热力图

Profiling web-edit with Python 3.15: flame graphs and source heatmaps

AI 导读

用 Python 3.15 内置的 `profiling.sampling` 对未修改的 web-edit 应用做采样剖析,发现混合换行符保留是编辑负载的主要开销:`preserve_endings` 出现在 15,296 个 CPU 栈的 64.8% 中,`SequenceMatcher.find_longest_match` 占叶子样本的 38.3%。

正文 · AI 翻译

研究 用 Python 3.15 对 web-edit 进行性能分析:火焰图与源码热力图 —— 使用 Python 3.15 内置的 `profiling.sampling` 对未经修改的 web-edit 应用进行性能分析后发现,混合行尾保留在繁忙的编辑工作负载中占主导地位:在记录的 15,296 个 CPU 栈中,`preserve_endings` 出现在 64.8% 的栈中,而 `SequenceMatcher.find_longest_match` 贡献了 38.3% 的叶子样本。对所有线程进行采样至关重要,因为 95.1% 的栈来自 AnyIO 的工作线程,仅分析主线程会遗漏这些栈。

我让 Codex 中的 GPT-6 Astra Extra High 用新的 Python 3.15 性能分析器对我新的 web-edit 应用进行了测试:

I need a Python 3.15 flame graph and heatmap demo of the "web-edit" app from PyPI - research first then make me those demos

以下是生成的示例火焰图和热力图。

来源:Simon Willison · simonwillison.net