summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2022-02-09 17:49:14 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-09 19:06:01 +0000
commita94caa502cf94fa6c8fcfea7283d7eaf3bd55ad5 (patch)
treeb9190c0408050244ab5a31e792ac5bb5422a63ff /jstests
parent32b042a2ed38d8a3f056b862cf6b13b36fb7ee4c (diff)
downloadmongo-a94caa502cf94fa6c8fcfea7283d7eaf3bd55ad5.tar.gz
SERVER-63102 Introduce internalQueryPlanEvaluationWorksSber5.3.0-alpha3
The 'internalQueryPlanEvaluationWorks' parameter now only affects the classic engine. The newly added parameter has similar behavior, but applies only to queries using SBE.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/explain_reports_correct_trial_period_statistics.js1
-rw-r--r--jstests/noPassthrough/query_knobs_validation.js9
-rw-r--r--jstests/noPassthrough/sbe_multiplanner_trial_termination.js33
3 files changed, 34 insertions, 9 deletions
diff --git a/jstests/noPassthrough/explain_reports_correct_trial_period_statistics.js b/jstests/noPassthrough/explain_reports_correct_trial_period_statistics.js
index 05289cfde86..eafce2c9a62 100644
--- a/jstests/noPassthrough/explain_reports_correct_trial_period_statistics.js
+++ b/jstests/noPassthrough/explain_reports_correct_trial_period_statistics.js
@@ -18,6 +18,7 @@ assert.commandWorked(coll.createIndex({b: 1}));
// Configure the server such that the trial period should end after doing 10 reads from storage.
assert.commandWorked(db.adminCommand({setParameter: 1, internalQueryPlanEvaluationWorks: 10}));
+assert.commandWorked(db.adminCommand({setParameter: 1, internalQueryPlanEvaluationWorksSbe: 10}));
assert.commandWorked(coll.insert(Array.from({length: 20}, (v, i) => {
return {a: 1, b: 1, c: i};
diff --git a/jstests/noPassthrough/query_knobs_validation.js b/jstests/noPassthrough/query_knobs_validation.js
index 219e9ce2e58..8ff22a20308 100644
--- a/jstests/noPassthrough/query_knobs_validation.js
+++ b/jstests/noPassthrough/query_knobs_validation.js
@@ -12,6 +12,7 @@ const conn = MongoRunner.runMongod();
const testDB = conn.getDB("admin");
const expectedParamDefaults = {
internalQueryPlanEvaluationWorks: 10000,
+ internalQueryPlanEvaluationWorksSbe: 10000,
internalQueryPlanEvaluationCollFraction: 0.3,
internalQueryPlanEvaluationCollFractionSbe: 0.0,
internalQueryPlanEvaluationMaxResults: 101,
@@ -86,9 +87,11 @@ assert.eq(getParamRes["internalPipelineLengthLimit"],
// Verify that the default values are set as expected when the server starts up.
assertDefaultParameterValues();
-assertSetParameterSucceeds("internalQueryPlanEvaluationWorks", 11);
-assertSetParameterFails("internalQueryPlanEvaluationWorks", 0);
-assertSetParameterFails("internalQueryPlanEvaluationWorks", -1);
+for (let paramName of ["internalQueryPlanEvaluationWorks", "internalQueryPlanEvaluationWorksSbe"]) {
+ assertSetParameterSucceeds(paramName, 11);
+ assertSetParameterFails(paramName, 0);
+ assertSetParameterFails(paramName, -1);
+}
for (let paramName of ["internalQueryPlanEvaluationCollFraction",
"internalQueryPlanEvaluationCollFractionSbe"]) {
diff --git a/jstests/noPassthrough/sbe_multiplanner_trial_termination.js b/jstests/noPassthrough/sbe_multiplanner_trial_termination.js
index 8918df3bdb1..75739587a9f 100644
--- a/jstests/noPassthrough/sbe_multiplanner_trial_termination.js
+++ b/jstests/noPassthrough/sbe_multiplanner_trial_termination.js
@@ -12,6 +12,7 @@ const collName = "sbe_multiplanner_coll";
const collFracKnob = "internalQueryPlanEvaluationCollFraction";
const collFracKnobSbe = "internalQueryPlanEvaluationCollFractionSbe";
const worksKnob = "internalQueryPlanEvaluationWorks";
+const worksKnobSbe = "internalQueryPlanEvaluationWorksSbe";
const defaultCollFrac = 0.3;
const trialLengthFromCollFrac = defaultCollFrac * numDocs;
@@ -46,7 +47,7 @@ for (let i = 0; i < numDocs; ++i) {
// collection. Since the classic multiplanner takes either the works limit or 30% of the collection
// size -- whichever is larger -- this should cause the trial period to run for about 0.3 * numDocs
// work cycles.
-const getParamRes = assert.commandWorked(db.adminCommand({getParameter: 1, [collFracKnob]: 1}));
+let getParamRes = assert.commandWorked(db.adminCommand({getParameter: 1, [collFracKnob]: 1}));
assert.eq(getParamRes[collFracKnob], defaultCollFrac);
assert.commandWorked(db.adminCommand({setParameter: 1, [worksKnob]: trialLengthFromWorksKnob}));
@@ -62,22 +63,42 @@ for (let plan of allPlans) {
assert.eq(executionStages.works, trialLengthFromCollFrac, plan);
}
-// Verifies that for each SBE plan in the 'allPlans' array, the number of storage reads done by the
-// plan is equal to 'expectedNumReads'.
-function verifySbeNumReads(allPlans, expectedNumReads) {
+// For each SBE plan in the 'allPlans' array, verifies the number of storage reads
+// done by the plan with respect to 'expectedNumReads' by calling 'assertionFn(actualNumReads,
+// expectedNumReads)'.
+//
+// By default, 'assertionFn' is 'assert.eq()' -- meaning that the number of storage cursor reads
+// done by each candidate SBE plan is checked exactly -- but the caller can pass a different
+// assertion function to override this behavior.
+function verifySbeNumReads(allPlans, expectedNumReads, assertionFn = assert.eq) {
for (let plan of allPlans) {
// Infer the number of reads (SBE's equivalent of work units) as the sum of keys and
// documents examined.
assert(plan.hasOwnProperty("totalKeysExamined"), plan);
assert(plan.hasOwnProperty("totalDocsExamined"), plan);
const numReads = plan.totalKeysExamined + plan.totalDocsExamined;
- assert.eq(numReads, expectedNumReads, plan);
+ assertionFn(numReads, expectedNumReads, plan);
}
}
-// Allow the query to use SBE. This time, the trial period should terminate based on the works knob.
+// Verify the default values of the SBE-specific knobs.
+getParamRes = assert.commandWorked(db.adminCommand({getParameter: 1, [collFracKnobSbe]: 1}));
+assert.eq(getParamRes[collFracKnobSbe], 0.0);
+getParamRes = assert.commandWorked(db.adminCommand({getParameter: 1, [worksKnobSbe]: 1}));
+assert.gt(getParamRes[worksKnobSbe], numDocs);
+
+// Allow the query to use SBE. Since we haven't modified any SBE-specific knobs yet, we expect the
+// length of the trial period to be determined by the default value of the SBE works knob. Since the
+// default value of SBE's works knob exceeds the size of the collection, we expect the number of
+// reads to exceed the collection size as well. By construction of the test, this also means that
+// the trial period length exceeds both 'trialLengthFromCollFrac' and 'trialLengthFromWorksKnob'.
assert.commandWorked(db.adminCommand({setParameter: 1, internalQueryForceClassicEngine: false}));
allPlans = getAllPlansExecution("2");
+verifySbeNumReads(allPlans, numDocs, assert.gt);
+
+// Setting the SBE works knob lower will reduce the length of the trial period.
+assert.commandWorked(db.adminCommand({setParameter: 1, [worksKnobSbe]: trialLengthFromWorksKnob}));
+allPlans = getAllPlansExecution("2");
verifySbeNumReads(allPlans, trialLengthFromWorksKnob);
// If the SBE "collection fraction" knob is set to the same value as the equivalent knob for the