-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: CLI arguments for configuring GraphQL query costs. #2335
base: master
Are you sure you want to change the base?
feat: CLI arguments for configuring GraphQL query costs. #2335
Conversation
7bf18ce
to
ec34236
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments and queries
wonder why the ci is failing for the test included in this pr. lgtm otherwise, the test passes locally. |
Yeah, I'll investigate it. It was the same with the previous parameters so something else is going on here but I have no idea what. |
Reproduced locally now. The test only fails for me with |
Alright, so the problem is that libtest will initialize |
Co-authored-by: Mårten Blankfors <marten@blankfors.se>
* Move query costs initialization function * Feature gate default implementation on "test-helpers" feature * Only set block header query cost in test
…es (e.g. for tests)" This reverts commit 35c7214.
8f93f4f
to
645db49
Compare
@@ -220,6 +221,8 @@ where | |||
OnChain::LatestView: OnChainDatabase, | |||
OffChain::LatestView: OffChainDatabase, | |||
{ | |||
graphql_api::initialize_query_costs(config.config.costs.clone())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a comment here about not moving this line will be nice. if it is moved later, calls to query_costs()
will yield the default value instead of the user's configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additionally, I have a question about the graphql query complexity annotations, are they evaluated at compile time or runtime?
answered my own question - they are evaluated at runtime within a closure (expanded macro) -
I assume here that for every query it will run the closure, which might be a red flag for graphql performance, because of the atomic operations done by OnceLock::get()
in the query_costs()
function.
will defer to @xgreenx here, but we should load test this PR to ensure there isn't a regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, the async graphql book mentions that all complexity calculations are done during the verification phase of the query (https://async-graphql.github.io/async-graphql/en/depth_and_complexity.html#custom-complexity-calculation).
I'm not sure if a load acquire operation is going to create too much overhead, as it is one of the lowest overhead synchronization primitives. But i agree that this should be load-tested, perhaps in a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the load testing can happen with the image generated by this pr on devnet and testnet, let's do that first
Linked Issues/PRs
Description
This PR adds CLI options to configure graphql query costs dynamically.
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]