-
Notifications
You must be signed in to change notification settings - Fork 275
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
Allow disabling PQ-based QP cache rewarm when reloading schemas #5990
Conversation
This comment has been minimized.
This comment has been minimized.
CI performance tests
|
9ea2b7c
to
d279aab
Compare
(experimental_pql_prewarm && previous_cache.is_none()) || previous_cache.is_some(); | ||
let should_warm_with_pqs = (experimental_pql_prewarm.on_startup | ||
&& previous_cache.is_none()) | ||
|| (experimental_pql_prewarm.on_reload && previous_cache.is_some()); |
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.
This line is the heart of the PR.
]), | ||
)) | ||
.persisted_query( | ||
PersistedQueries::builder() |
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.
Switching to using the builder seemed more legible if I had to update this anyway.
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.
this looks great, thanks for tackling this so quickly!
In #3829 we taught router to use the PQ list to prewarm the query planner cache when reloading its schema. In #5340 we gave it the experimental option to do the same thing at startup. Now we are allowing you to turn off the on-reload prewarm. Because the PQ list does not have metadata to tell the Router which PQs have been used recently, if you have a large PQ list then the on-reload prewarm can slow down schema updates noticeably, and it may not provide much value over prewarming based on the contents of the in-memory QP cache itself. We keep the same defaults, but let you turn off the on-reload prewarm with: ``` persisted_queries: experimental_prewarm_query_plan_cache: on_reload: false ``` Previously, `persisted_queries.experimental_prewarm_query_plan_cache` was a boolean; a migration moves this boolean to `persisted_queries.experimental_prewarm_query_plan_cache.on_startup`. (`on_startup` defaults to false and `on_reload` defaults to true.) This migration uses a `type: change` action. No such actions existed in the codebase and the implementation appeared to be buggy: there is no top-level `==` operator (or top-level operators at all) in JSONPath. This PR fixes the implementation of `type: change` to use the `[?(@.x == y)]` filter syntax which does appear to work (as tested by the migration tests for the new migration). This also renames a migration file added in #5957 that used a non-standard filename.
d279aab
to
f175271
Compare
@@ -144,7 +144,7 @@ fn apply_migration(config: &Value, migration: &Migration) -> Result<Value, Confi | |||
} | |||
} | |||
Action::Change { path, from, to } => { | |||
if !jsonpath_lib::select(config, &format!("$.{path} == {from}")) |
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.
FWIW this syntax just seemed to be wrong (and the library ignored everything after the space without an error?)
https://freestrings.github.io/jsonpath/ can be used to test this jsonpath_lib implementation.
@@ -63,6 +61,8 @@ supergraph: | |||
warmed_up_queries: 100 | |||
``` | |||
|
|||
(In addition, the router can use the contents of the [persisted query list](./persisted-queries) to prewarm the cache. By default, it does this when loading a new schema but not on startup; you can [configure](./persisted-queries#persisted-queries#experimental_prewarm_query_plan_cache) it to change either of these defaults.) |
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.
I think I might have gotten this wrong from the slack convo, but aren't we changing the default to be "warm PQs at startup" with an additional option to "warm PQs at schema reload"?
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.
We're changing it so that you can disable pre-warming on schema change which is a default behavior at the moment. Warming PQs on startup is an option that remains unchanged.
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.
(although the option's name is changing, with migration)
In #3829 we taught router to use the PQ list to prewarm the query planner cache when reloading its schema.
In #5340 we gave it the experimental option to do the same thing at startup.
Now we are allowing you to turn off the on-reload prewarm.
Because the PQ list does not have metadata to tell the Router which PQs have been used recently, if you have a large PQ list then the on-reload prewarm can slow down schema updates noticeably, and it may not provide much value over prewarming based on the contents of the in-memory QP cache itself.
We keep the same defaults, but let you turn off the on-reload prewarm with:
Previously,
persisted_queries.experimental_prewarm_query_plan_cache
was a boolean; a migration moves this boolean topersisted_queries.experimental_prewarm_query_plan_cache.on_startup
. (on_startup
defaults to false andon_reload
defaults to true.)This migration uses a
type: change
action. No such actions existed in the codebase and the implementation appeared to be buggy: there is no top-level==
operator (or top-level operators at all) in JSONPath. This PR fixes the implementation oftype: change
to use the[?(@.x == y)]
filter syntax which does appear to work (as tested by the migration tests for the new migration).This also renames a migration file added in #5957 that used a non-standard filename.
Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
I'm not sure where to put tests of the prewarming functionality; neither #3829 nor #5340 appear to have tests. (The migration is tested.)
Exceptions
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩