Performance issues related to complete_value on large datasets
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- api, performance
调研方向
从 execute.py 中的 ExecutionContext.complete_value、complete_list_value 和 complete_object_value 开始,以报告的 graphql.py 调用路径作为复现入口。在 Python 3.8 和 graphql-core 3.2.3 上复现包含 5,000 个元素的嵌套查询,对执行过程进行性能分析,并验证任何更改都会在不改变返回结果的情况下减少开销。
由索引模型根据 Issue 内容生成。
描述
Hi! We've noticed that returning a list of 5k elements, with a couple of nested objects is pretty slow:
Person {
id
name
lastname
age
address {street number}
job {id org_name}
partner {id name}
pets {name type}
school {id name}
}

| ncalls | tottime | percall | cumtime | percall | filename:lineno(function) |
|---|---|---|---|---|---|
| 1 | 1.8e-05 | 1.8e-05 | 2.145 | 2.145 | graphql.py:103(graphql_sync) |
| 1 | 1.5e-05 | 1.5e-05 | 2.145 | 2.145 | graphql.py:152(graphql_impl) |
| 1/30001 | 0.19 | 6.335e-06 | 2.137 | 7.122e-05 | execute.py:413(ExecutionContext.execute_fields) |
| 1 | 1.3e-05 | 1.3e-05 | 2.137 | 2.137 | execute.py:965(execute) |
| 1 | 7e-06 | 7e-06 | 2.137 | 2.137 | execute.py:328(ExecutionContext.execute_operation) |
| 1/135001 | 0.3229 | 2.392e-06 | 2.135 | 1.581e-05 | execute.py:485(ExecutionContext.execute_field) |
| 1/145001 | 0.2737 | 1.888e-06 | 2.071 | 1.428e-05 | execute.py:575(ExecutionContext.complete_value) |
| 1 | 0.009884 | 0.009884 | 2.071 | 2.071 | execute.py:660(ExecutionContext.complete_list_value) |
| 5000/30000 | 0.02747 | 9.156e-07 | 2.026 | 6.752e-05 | execute.py:893(ExecutionContext.complete_object_value) |
By itself it's not really a slow function, but its executed 30k times. Is there any way to reduce the overhead by reducing the number of times this function is invoked?
Tested on Python 3.8 and graphql-core==3.2.3
- 主要语言
- Python
- 星标
- 531
- 派生
- 147
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
graphql-python/graphql-core 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 50/100
graphql-python/graphql-core#272 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 55/100
graphql-python/graphql-core#269 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
graphql-python/graphql-core#267 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
graphql-python/graphql-core#257 ·
-
难度 5/5 一周以上 新手友好度 25/100
graphql-python/graphql-core#247 · 8 条评论 ·
查看 graphql-python/graphql-core 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/skills#1811 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
speaches-ai/speaches#678 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
datalayer/mcp-compose#42 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
conda-forge/spacy-feedstock#177 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
UKGovernmentBEIS/inspect_evals#2523 ·