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

fix: Improve child-doc resolver Performance #54

Merged
merged 5 commits into from
Dec 11, 2021

Conversation

fahimalizain
Copy link
Member

@fahimalizain fahimalizain commented Nov 24, 2021

Preface

  • get_cached_doc was being called for each and every document being handled by gql-resolver be it child-doc or normal-doc.
  • get_cached_doc works as indented - loads from db on first call, serves from cache on second call
  • permission check is not required for child docs.
  • Number of db calls on a single get_doc is huge

Observations

Before & After

Query:

{
  Users(first: 100) {
    pageInfo {
      hasNextPage hasPreviousPage startCursor endCursor
    }
    totalCount
    edges {
      cursor
      node {
        full_name
        email
        roles {
          role__name
        }
      }
    }
  }
}

Before:
image

After:
image

Significant drop in number of queries can be observed.
There is a lot more room for improvements - let this be the first step 😄

Copy link
Collaborator

@Abadulrehman Abadulrehman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@fahimalizain
Copy link
Member Author

https://gqlgen.com/reference/dataloaders/
This is where we should be headed 👀

@e-lobo
Copy link
Member

e-lobo commented Nov 24, 2021

https://gqlgen.com/reference/dataloaders/ This is where we should be headed 👀

https://github.com/syrusakbary/aiodataloader
this maybe..

@fahimalizain
Copy link
Member Author

The dataloader implementations I have seen requires ASGI 🙆🏼‍♂️

@e-lobo
Copy link
Member

e-lobo commented Nov 24, 2021

ahh hence the await i was wondering about that..

@fahimalizain
Copy link
Member Author

Related: #53

@fahimalizain
Copy link
Member Author

@e-lobo found a bug with __ignore_perms
will continue working with this PR adding a basic test-suite for document_resolver.py

@fahimalizain fahimalizain added the WIP Work In Progress label Nov 25, 2021
@fahimalizain fahimalizain removed the WIP Work In Progress label Nov 30, 2021
@fahimalizain fahimalizain requested a review from e-lobo December 8, 2021 01:56
Copy link
Collaborator

@Abadulrehman Abadulrehman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@fahimalizain fahimalizain merged commit 5b760bb into master Dec 11, 2021
@fahimalizain fahimalizain deleted the perf-cached-child-doc branch February 3, 2022 05:10
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.

3 participants