Skip to content

Reduce repeated type checks during schema reconstruction #300

Closed

Description

@dexhunter

Rebuilding a large schema repeatedly calls type-check helpers for references already collected.
The repository's GitHub schema recreation benchmark takes 1.310 ms per call in my measurements.

A small change to TypeSet.collect_referenced_types uses direct class checks and skips repeated work.
It preserves type order, lazy lookups, and errors.

Situation Before With proposed change Change
Recreate the GitHub schema 1.310 ms 0.903 ms 31.0% less time
Build a schema from introspection 14.959 ms 14.713 ms 1.6% less time
Execute an async iterable list field 1.212 ms 1.199 ms 1.1% less time
Decode a pickled large-query AST 6.955 ms 6.957 ms No measurable change

These are median times on the same isolated CPU, using CPython 3.12.13 and Linux x86-64.
The source is graphql-core 3.3.1 at commit 0aaea717d8a6ca4e7241fb798ff4f0216dde61ee.

Reproduction:

PYTHONPATH=src python -m pytest tests/benchmarks/test_graphql_schema.py \
  tests/benchmarks/test_build_client_schema.py \
  tests/benchmarks/test_async_iterable.py \
  tests/benchmarks/test_serialization.py --benchmark-enable

The native suite passes with the change: 3,625 passed and 18 skipped.
AI assistance: Codex gpt-6.1-sol generated the candidate, and Weco Observe recorded its measurements.

I have a tested patch ready and would be glad to open a pull request if this approach fits the project.

Activity

  1. Cito commented on Nov 6, 2026

    @Cito
    Member

    Done in #301, part of 3.3.2.

  2. changed the title [-]# Reduce repeated type checks during schema reconstruction[/-] [+]Reduce repeated type checks during schema reconstruction[/+] on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions