-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve: optimize graphql runtime #3372
Comments
@StevenACoffman I took benchmark using goccy/go-json instead of encoding/json, total memory usage is 1.15% (832 B / 720 B) optimized. I created PR #3405 |
@lkeix the benchmarking is very helpful! In #2842 it was proposed to allow JSON configuration to be configurable, and several people in the community have warned me against defaulting to using goccy/go-json as in this comment. In #2757 it was suggested to that there are more than one alternative JSON encoding library people might want to use: Some of these libraries include:
See related: |
What happened?
The
transport.Post
implementation in theDo
method has potential for optimization. Specifically, two areas could improve performance:Do
method frequently converts[]byte
tostring
, which incurs additional allocations.graphql.RawParams
could benefit from async.Pool
to reduce allocations and reuse memory.What did you expect?
Optimizing memory allocation in the
Do
method should lead to better overall performance for the gqlgen server, especially for high-throughput applications.Minimal graphql.schema and models to reproduce
I tested using the gqlgen initial schema and an empty slice return for the
Todos
query, observing allocation patterns during benchmarking.Versions
v0.17.55
(viago run github.com/99designs/gqlgen version
)go1.23.2 darwin/amd64
Pull Request
#3373
The text was updated successfully, but these errors were encountered: