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

chore(federation): add unit tests and documentation for conditions handling #6325

Merged
merged 6 commits into from
Nov 22, 2024

Conversation

goto-bus-stop
Copy link
Member

@goto-bus-stop goto-bus-stop commented Nov 22, 2024

The Conditions structure represents the combined skip/include conditions of a GraphQL query path (and of a FetchDependencyGraphNode).

The storage of variable conditions looks inefficient. I tried some quick refactors to make it more efficient, which didn't hugely affect overall planning performance, even on plans that spend a lot of time computing conditions. Perhaps the representation isn't the biggest issue. I think we can still simplify it, though. I might tinker with that if I find some spare cycles in December.

This PR does not change the representation. I only added tests and documentation.

I also flipped the order of the update_with() argument. The order of the arguments disagreed with the name of the method. We were not updating the argument at all: we were updating self, removing conditions already handled by the argument.

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Nov 22, 2024

✅ Docs Preview Ready

No new or changed pages found.

Copy link
Contributor

@goto-bus-stop, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

@@ -46,6 +53,28 @@ pub(crate) enum Conditions {
Boolean(bool),
}

impl Display for Conditions {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is mostly for use in tests, though it might help with debugging as well

@router-perf
Copy link

router-perf bot commented Nov 22, 2024

CI performance tests

  • connectors-const - Connectors stress test that runs with a constant number of users
  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

@@ -1779,7 +1779,7 @@ impl FetchDependencyGraph {
.graph
.node_weight_mut(node_index)
.ok_or_else(|| FederationError::internal("Node unexpectedly missing"))?;
let conditions = handled_conditions.update_with(&node.selection_set.conditions);
let conditions = node.selection_set.conditions.update_with(&handled_conditions);
Copy link
Member Author

Choose a reason for hiding this comment

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

Only usage site of update_with().

goto-bus-stop added a commit that referenced this pull request Nov 22, 2024
While I was working on #6325, I figured I might as well tackle this
related issue quickly.

Certain graph and query shapes cause the `FetchSelectionSet::conditions`
to be recomputed very, very frequently. Now, they are only recomputed
when required.

On most plans there is no noteworthy difference.

When `OnceLock::get_or_try_init` is stabilised, this will be easier :)

<!-- [ROUTER-484] -->
Copy link
Member

@lrlna lrlna left a comment

Choose a reason for hiding this comment

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

I like always and never as an api to conditions!

@goto-bus-stop goto-bus-stop merged commit dc0426c into dev Nov 22, 2024
13 checks passed
@goto-bus-stop goto-bus-stop deleted the renee/conditions-docs branch November 22, 2024 13:23
goto-bus-stop added a commit that referenced this pull request Nov 22, 2024
While I was working on #6325, I figured I might as well tackle this
related issue quickly.

Certain graph and query shapes cause the `FetchSelectionSet::conditions`
to be recomputed very, very frequently. Now, they are only recomputed
when required.

On most plans there is no noteworthy difference.

When `OnceLock::get_or_try_init` is stabilised, this will be easier :)

<!-- [ROUTER-484] -->
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