[Regression]: evaluate() with larger results ~40% slower since 1.65
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 62/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- python
- 領域
- performance
研究方向
Start in protocol/validator_primitives.py, reading t_object and the t_optional helper, and trace where SerializedValue's schema keys are iterated. Before editing, run the issue's page.evaluate benchmark script to record a baseline, then re-run it after skipping the optional-key validators when a key is absent. Also run the protocol validator tests in tests/ (the suite that round-trips validated messages) to confirm malformed messages are still rejected. Done means the benchmark is back near 1.30s with unchanged validation behaviour, including for events and initializers.
由索引模型根據 Issue 內容生成。
描述
Last Good Version
1.64.0
First Bad Version
1.65.0
Steps to reproduce
evaluate() with a medium-sized result got about 40% slower:
import time
from playwright.sync_api import sync_playwright
JS = "Array.from({length: 200}, (_, i) => ({id: i, name: 'item ' + i, price: i * 1.5, url: 'https://example.com/' + i, tags: ['a', 'b']}))"
with sync_playwright() as p:
page = p.chromium.launch().new_page()
page.evaluate(JS)
best = 1e9
for _ in range(3):
start = time.perf_counter()
for _ in range(300):
page.evaluate(JS)
best = min(best, time.perf_counter() - start)
print(f"{best:.2f}s")
Expected behavior
1.64.0: 1.30s
Actual behavior
1.65.2: 1.84s
Additional context
cProfile points at the protocol validator: the t_object validator in protocol/validator_primitives.py is about 60% of the profiled time. For every object node it calls the validator of every key in the schema, and SerializedValue has ~15 optional keys, so most calls are t_optional(None) for keys that aren't there. It also calls context.is_under_test() once per node.
Skipping the call when the key is absent and the validator is a t_optional (the result is None in that case anyway) brings the script above to 1.47s in my test, same output. Validated messages also include every event and initializer, so it's not only evaluate.
Environment
- Operating System: macOS 27.2
- CPU: arm64
- Browser: Chromium
- Python Version: 3.14
- Other info:
- 主要語言
- Python
- 星號
- 15.1k
- 分支
- 1.3k
- 平均合併
- 6 小時 16 分鐘
- 30 天內合併 PR
- 53
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/playwright-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
microsoft/playwright-python#3361 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
microsoft/playwright-python#3360 ·
維護者通常 1 天內回覆
查看 microsoft/playwright-python 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 88/100
snap-stanford/Biomni#380 ·
-
documentation priority: low size: S status: needs triage
難度 2/5 1-3 小時 新手友好度 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
維護者通常 1 天內回覆
-
documentation priority: low size: S status: needs triage
難度 2/5 1-3 小時 新手友好度 72/100
cubrid-lab/pycubrid#1307 ·
維護者通常 1 天內回覆
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't work未關閉bug
難度 2/5 1-3 小時 新手友好度 80/100
ShaftHQ/chaosengine-harness#143 ·
維護者通常 1 天內回覆
-
bug high-severity
難度 2/5 1-3 小時 新手友好度 72/100
aws/bedrock-agentcore-sdk-python#752 ·
維護者通常 1 天內回覆