From efdce1e72f2bb1148e491ed7d4f575cc7197965f Mon Sep 17 00:00:00 2001 From: "Sachin D. Shinde" Date: Wed, 7 Aug 2024 14:54:05 -0700 Subject: [PATCH 1/2] Remove concat() from ConditionValidationState.advance(), which greatly increases performance in some cases --- query-graphs-js/src/conditionsValidation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/query-graphs-js/src/conditionsValidation.ts b/query-graphs-js/src/conditionsValidation.ts index 7bae900ad..7763c170c 100644 --- a/query-graphs-js/src/conditionsValidation.ts +++ b/query-graphs-js/src/conditionsValidation.ts @@ -25,7 +25,7 @@ class ConditionValidationState { ) {} advance(supergraph: Schema): ConditionValidationState[] | null { - let newOptions: SimultaneousPathsWithLazyIndirectPaths[] = []; + const newOptions: SimultaneousPathsWithLazyIndirectPaths[] = []; for (const paths of this.subgraphOptions) { const pathsOptions = advanceSimultaneousPathsWithOperation( supergraph, @@ -40,7 +40,7 @@ class ConditionValidationState { if (!pathsOptions) { continue; } - newOptions = newOptions.concat(pathsOptions); + newOptions.push(...pathsOptions); } // If we got no options, it means that particular selection of the conditions cannot be satisfied, so the From c08c2f948f0f32e23b6191d500ad1c6b65b6f60d Mon Sep 17 00:00:00 2001 From: "Sachin D. Shinde" Date: Wed, 21 Aug 2024 10:08:18 -0700 Subject: [PATCH 2/2] Add changeset --- .changeset/fast-points-wonder.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/fast-points-wonder.md diff --git a/.changeset/fast-points-wonder.md b/.changeset/fast-points-wonder.md new file mode 100644 index 000000000..710f230b1 --- /dev/null +++ b/.changeset/fast-points-wonder.md @@ -0,0 +1,7 @@ +--- +"@apollo/federation-internals": patch +"@apollo/gateway": patch +"@apollo/composition": patch +--- + +Reduce memory overhead during satisfiability checking when there are many options.