Skip to content
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

introduces mapSchemaConfig utility function #4297

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Nov 19, 2024

motivation:

  1. rebuilds lexicographicallySortSchema on this generic utility, better demonstrating only the sorting
  2. rebuilds extendSchemaImpl on this utility
  3. can be used as base to more easily enhance extendSchema/buildASTSchema/buildSchema to take resolvers, etc
  4. can be used to expose a generic safe mapSchema utility

TO DO: improve test coverage

@yaacovCR yaacovCR requested a review from a team as a code owner November 19, 2024 11:23
Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit e495a3f
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/67450d5b1b5cbe0008ab9706
😎 Deploy Preview https://deploy-preview-4297--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

@yaacovCR yaacovCR changed the title introduces mapSchema function introduces mapSchemaConfig function Nov 19, 2024
@yaacovCR
Copy link
Contributor Author

note: diff is easier to scan when hiding whitespace

@yaacovCR yaacovCR changed the title introduces mapSchemaConfig function introduces mapSchemaConfig utility function Nov 19, 2024
extracting this from lexicographicallySortSchema
and extendSchemaImpl

motivation:
1. to use to further enhance extendSchema/buildASTSchema/buildSchema to take resolvers, etc, and
2. to expose a generic safe mapSchemaConfig
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Nov 21, 2024

This re-implementation brings a 24% performance boost to buildSchema() and a small drop in memory use.

image

I'm not sure yet what exactly brings the performance boost, I was just hoping for parity.

@yaacovCR
Copy link
Contributor Author

Just poking around a bit with deopt-explorer, which, as usual, is beyond me, but the summary for main is:

image

and the summary for map is:

image

For clarity, within the map version, we rename getWrappedType() to typeFromAST() and getNamedType() to namedTypeFromAST() because it allows us to use getNamedType() in the SchemaContext closure without a clash -- and these functions essentially are a pre-GraphQLSchema-creation version of our typeFromAST() utility with the exact same algorithm.

For clarity, I also renamed buildType() to buildNamedType().

So the thing that leaps out at me is that the number of deoptimizations in buildType()/buildNamedType() and extendSchemaImpl() drop, the former significantly. I am not 100% on why. I can only guess that splitting the functions into smaller bits helped.

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