Skip to content

fix(composition): Use a priority queue instead of a stack for satisfiability #3258

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

Open
wants to merge 2 commits into
base: version-2.10
Choose a base branch
from

Conversation

sachindshinde
Copy link
Contributor

@sachindshinde sachindshinde commented May 14, 2025

This PR updates satisfiability logic to use a (heap-based) priority queue instead of a stack to store validation state, where a state is higher priority if it has less possible subgraph paths. This is because supergraphs with high connectivity can lead to states with many possible subgraph paths for a supergraph path, and repeatedly processing such states can cause an explosion in possible subgraph paths in the worst case. To avoid this explosion, we prioritize supergraph paths with fewer possible subgraph paths, and this helps us reach more types using smaller states in practice. Loop detection then prevents us from having to consider the larger states to begin with.

@sachindshinde sachindshinde requested a review from a team as a code owner May 14, 2025 22:35
Copy link

changeset-bot bot commented May 14, 2025

🦋 Changeset detected

Latest commit: 252cc9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@apollo/composition Patch
@apollo/gateway Patch
@apollo/federation-internals Patch
@apollo/query-planner Patch
@apollo/query-graphs Patch
@apollo/subgraph Patch
apollo-federation-integration-testsuite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented May 14, 2025

⚠️ Docs preview not attached to branch

The preview was not built because the PR's base branch version-2.10 is not in the list of sources.

An Apollo team member can comment one of the following commands to dictate which branch to attach the preview to:

  • !docs set-base-branch version-0.x
  • !docs set-base-branch main

Build ID: 549ed4f49f804d0d3a73b682

Copy link

codesandbox-ci bot commented May 14, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@sachindshinde sachindshinde changed the title Use a priority queue instead of a stack for satisfiability fix(composition): Use a priority queue instead of a stack for satisfiability May 14, 2025
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.

2 participants