Skip to content

Perf/allocations - #70

Merged
docelic merged 2 commits into
graphql-crystal:mainfrom
docelic:perf/allocations
Oct 9, 2026
Merged

docelic merged 2 commits into
graphql-crystal:mainfrom
docelic:perf/allocations

Conversation

@docelic

@docelic docelic commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Measured with the benchmark's new allocation column (heap bytes per
request from GC.stats), before and after on the same machine:

  scenario            alloc/req     req/s
  small               -34%          +46%
  flat_list           -41%          +37%
  nested_tree         -26%          +32%
  nested_concurrent   -21%          +28%
  union_fragments     -25%          +18%
  mutations           -25%          +18%
  introspection       -27%          +30%

Per request: nodes keep their source offset and derive line and column
only when an error needs them, instead of the parser building a line
table for every query; list parsing takes blocks instead of allocating
a Proc per call; nodes without arguments, directives, selections or
variables share frozen empty arrays; node constructors re-map an array
only when its element type must widen; operations are found by scanning
definitions rather than visiting the whole tree into an array; and a
request without a `$` skips variable resolution and substitution.

Per object: plain selection sets (fields only, no directives, distinct
keys) are resolved directly without collecting into a map, and the
collection step that remains uses an array; leaf fields, leaf lists and
successful fragments return one shared empty error array instead of
allocating their own; sequential list elements are buffered inline
without a closure, a pending slot or a path array each.
@docelic
docelic merged commit aa6f108 into graphql-crystal:main Oct 9, 2026
2 checks passed
@docelic
docelic deleted the perf/allocations branch October 9, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant