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

Type conditioned fetching #4748

Merged
merged 55 commits into from
Apr 24, 2024
Merged

Type conditioned fetching #4748

merged 55 commits into from
Apr 24, 2024

Conversation

o0Ignition0o
Copy link
Contributor

@o0Ignition0o o0Ignition0o commented Mar 5, 2024

Type conditioned fetching (PR #4748)

Type conditioned fetching

When querying a field that is in a path of 2 or more unions, the query planner was not able to handle different selections and would aggressively collapse selections in fetches yielding an incorrect plan.

This change introduces an experimental configuration option to enable type conditioned fetching:

experimental_type_conditioned_fetching: true # false by default

By @o0Ignition0o in #4748

This comment has been minimized.

@router-perf
Copy link

router-perf bot commented Mar 5, 2024

CI performance tests

  • reload - Reload test over a long period of time at a constant rate of users
  • 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_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • large-request - Stress test with a 1 MB request payload
  • const - Basic stress test that runs with a constant number of users
  • no-graphos - Basic stress test, no GraphOS.
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • 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_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • xxlarge-request - Stress test with 100 MB request payload
  • xlarge-request - Stress test with 10 MB request payload
  • step - Basic stress test that steps up the number of users over time

@o0Ignition0o o0Ignition0o changed the title wip: type conditioned fetching Type conditioned fetching Apr 22, 2024
@o0Ignition0o o0Ignition0o marked this pull request as ready for review April 22, 2024 12:36
Cargo.lock Outdated Show resolved Hide resolved
apollo-router/src/json_ext.rs Show resolved Hide resolved
apollo-router/src/query_planner/bridge_query_planner.rs Outdated Show resolved Hide resolved
apollo-router/src/configuration/mod.rs Outdated Show resolved Hide resolved
apollo-router/src/json_ext.rs Outdated Show resolved Hide resolved
@@ -21,6 +24,11 @@ pub(crate) type Object = Map<ByteString, Value>;

const FRAGMENT_PREFIX: &str = "... on ";

static TYPE_CONDITIONS_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"(?:\|\[)(.+?)(?:,\s*|)(?:\])")
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Maybe easier to understand when captures are used if these are named.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in d14d077

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is really fixed. I can see that you've named one of the groups "", but I can't see where it's being used. It looks like you are still using the indices of the various captures.

e.g.:

        let path = TYPE_CONDITIONS_REGEX.replace(s, |caps: &Captures| {
            type_conditions.extend(
                caps.extract::<1>()
                    .1
                    .map(|s| s.split(',').map(|s| s.to_string()))
                    .into_iter()
                    .flatten(),
            );
            ""
        });

You are always using extract, group 1, which is a bit opaque. If you want to use the name then it would be something like: caps.name("condition") and you'd need to do some handling for not being present.

Anyway, it was a NIT, so I'm fine with the extract approach that you are using, in which case no need to name the capture group.

If you do think it's worth naming the various capture groups, then you should use them to make the code a bit less opaque when you are pulling out the conditions as I outlined above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually fixed in 6c67cac 😁

Copy link
Contributor

Choose a reason for hiding this comment

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

Now you are making me feel really picky, but there multiple used of extract(). May as well change all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's followup on that!

apollo-router/src/json_ext.rs Outdated Show resolved Hide resolved
@o0Ignition0o o0Ignition0o enabled auto-merge (squash) April 24, 2024 12:34
@o0Ignition0o o0Ignition0o merged commit 55e86c8 into dev Apr 24, 2024
14 checks passed
@o0Ignition0o o0Ignition0o deleted the igni/type_conditioned_fetching branch April 24, 2024 12:52
@BrynCooke BrynCooke mentioned this pull request May 7, 2024
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.

None yet

4 participants