Proposal: gqlgen performance improvements
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
In our monorepo, with ~140 `.graphql` files spread across 3 different apps (i.e different gqlgen config files), `gqlgen` takes ~74s to execute.
This time has been creeping up over time as the team is adding new graphql surface area and the time it takes to regenerate files is in the critical path both for development iteration (graphql files have to be generated and then the Go server has to rebuilt) and in CI (for verifying that there are no changes to checked in generated files). The above timing is inclusive of everything we tried to speed this `gqlgen` up like `skip_validation: true` and `skip_mod_tidy: true`.
After some profiling, it seems like most of the time is spent inside `packages.Load` with `NeedTypes` where it forks `go list -json` which triggers partial compilation. From my research, it seems like there might be places where we can avoid this costly operation.
I want to take a stab at implementing a few performance improvements to make generation much faster (~10x improvement seems achievable from experimentation). My plan is to validate gqlgen changes by switching our internal build to use a fork and then if viable, contribute the improvements upstream.
Is there an existing on-going effort to speed up gqlgen that I should be aware of before I start? Outside of the existing unit tests, are there other means to validating my changes?
贡献指南
调研方向
该 issue 指出了 `packages.Load` 在使用 `NeedTypes` 时的性能瓶颈。首先对当前的 gqlgen 代码库进行性能分析,尤其是代码生成路径。查看现有的单元测试和 gqlgen 配置结构。成功的修改应显著减少大型 schema 的生成时间,并通过将一个内部构建切换到 fork 来验证。
由索引模型根据 Issue 内容生成。
评估
- 领域
- backend-api-design, devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 20/100