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

BUG: Fixer high GitHub API usage #1623

Closed
azeemshaikh38 opened this issue Feb 11, 2022 · 2 comments · Fixed by #1643
Closed

BUG: Fixer high GitHub API usage #1623

azeemshaikh38 opened this issue Feb 11, 2022 · 2 comments · Fixed by #1643
Assignees
Labels
kind/bug Something isn't working

Comments

@azeemshaikh38
Copy link
Contributor

#1566 increases the cost/complexity of the GraphQL queries. The query cost goes up ~20x due to that PR. We should fix this before the next release. 2-part solution here:

  1. Decrease the number of associatedPullRequests to 1, since for every commit we are only interested in a single PR (the one used to submit the commit). Doing this brings back the cost to original, so ~20x savings.
  2. Add some tests to verify the cost of our GraphQL queries. Any future issues can be caught using these tests.

I would say, we block the next release on this issue since IMO it's important to fix this.

@laurentsimon
Copy link
Contributor

laurentsimon commented Feb 11, 2022

Can you explain how you compute the cost of a request? Is this something the API returns?
I don't follow why setting associatedPullRequests to 1 helps: I was under the impression that each commit to main has a single associated pull request anyway. I tried

{
  repository(owner: "ossf", name: "scorecard") {
    defaultBranchRef {
      target {
        ... on Commit {
          history(first: 10) {
            nodes {
              associatedPullRequests(first: 30) {
               
                  mergeCommit {
                    oid
                

and it seems to return a single PR for each commit. I've not looked at the code we use in scorecard though, but I think it's similar.

@azeemshaikh38
Copy link
Contributor Author

Can you explain how you compute the cost of a request? Is this something the API returns?

Yes, you can add the RateLimit object to the graphQL query to get the cost of the query - https://docs.github.com/en/graphql/reference/objects#ratelimit

I don't follow why setting associatedPullRequests to 1 helps: I was under the impression that each commit to main has a single associated pull request anyway.

That is correct. But if you say first: 1 vs. first: 30 (for associatedPR), the cost of the query that you get is different. I presume GitHub makes an approximate charge based on the complexity of the query, so a query for more items is more expensive even if it ends up returning lesser number of items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants