Skip to content

perf(router): box the plan nodes - #1533

Merged
kamilkisiela merged 5 commits into
kamil-qp-cache-pr2from
kamil-qp-cache-pr3
Sep 14, 2026
Merged

kamilkisiela merged 5 commits into
kamil-qp-cache-pr2from
kamil-qp-cache-pr3

Conversation

@kamilkisiela

Copy link
Copy Markdown
Contributor

PlanNode is an enum, so every variant takes as much space as its largest variant. Some of the variants have a subgraph fetch, and those were much larger than the rest. They are now boxed.

@kamilkisiela
kamilkisiela added this pull request to stack #1534 September 10, 2026 11:37
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🐋 This PR was built and pushed to the following Docker images:

Image Names: ghcr.io/graphql-hive/router

Platforms: linux/amd64,linux/arm64

Image Tags: ghcr.io/graphql-hive/router:pr-1533 ghcr.io/graphql-hive/router:sha-ebc5a6a

@kamilkisiela
kamilkisiela marked this pull request as ready for review September 10, 2026 13:54
`PlanNode` sizes every slot of every `Sequence` and `Parallel` list, whether or
not that slot holds a fetch. Four of its eight variants were an order of
magnitude larger than the rest, so a plan of ten sequenced nodes paid for ten
`FetchNode`-sized slots regardless of what it actually contained.

Box those four. The enum drops from 224 B to 40 B per slot; the ceiling is now
`ConditionNode`, pinned in `stored_sizes_stay_small` alongside it so a future
field there stays visible.

The 184 B this saves per slot is smaller than it would have been before the
previous commit, which took the inline parsed document out of `FetchNode` and
`PlanNode` with it - 328 B to 224 B. Boxing first would have claimed 288 B and
left the document change claiming less; the total is the same either way.

`Box<T>` is transparent to serde in both directions, so the wire form does not
move and no snapshot changes.
@kamilkisiela
kamilkisiela merged commit 47cba2c into main Sep 14, 2026
30 of 31 checks passed
@kamilkisiela
kamilkisiela deleted the kamil-qp-cache-pr3 branch September 14, 2026 07:32
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.

2 participants