|
Ran
|
Jobs
1
|
Files
0
|
Run time
1min
|
Badge
README BADGES
|
push
github
perf: build the "no child fields" error lazily, without a global var (#4293) * perf: share the "no child fields" error across all fields of a scalar/enum type graphql.NewScalarFieldContext's fast path (introduced in #4086 for argument-less scalar/enum fields) built a fresh error via errors.New(...) on every single field resolution, even though the message only depends on the GraphQL type name and there's a small, fixed set of those per schema. #4086's own verbose fallback path (fields with args) already constructs this error lazily inside the Child closure; only the fast path evaluated it eagerly as a function argument. Add Data.UniqueScalarChildFieldErrors, mirroring the existing UniqueChildFieldTypes/childFields_* pattern, to emit one shared error value per distinct scalar/enum type name, and have the fast-path template reference it instead of calling errors.New per field. NewScalarFieldContext's signature is unchanged — this only changes what gets passed into it. Benchmark on _examples/todo's fieldContext_Todo_id, before/after, 100% of the delta accounted for by the removed errors.New call: before: 48.36 ns/op 184 B/op 3 allocs/op after: 40.69 ns/op 168 B/op 2 allocs/op On a production schema with several hundred scalar/enum-typed fields, this removes one allocation per field per request, unconditionally, regardless of query shape. * Revert "perf: share the "no child fields" error across all fields of a scalar/enum type" This reverts commit 2fdbbdd66. * perf: build the "no child fields" error lazily, without a global var @StevenACoffman objected to the shared-global-error approach from the previous commit: gqlgen is actively moving away from package-level mutable state (RULES.md #9), and generated code/templates should stay simple. @korotin proposed a compromise: keep NewScalarFieldContext's fast path, but pass the scalar/enum type name instead of a pre-built error, and build the error lazil... (continued)
0 of 0 relevant lines covered (NaN%)
0.0 hits per line
| ID | Job ID | Ran | Files | Coverage | |
|---|---|---|---|---|---|
| 1 | 35136891423.1 | 0 |
0.0
|
GitHub Action Run |