summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorRushan Chen <rushan.chen@mongodb.com>2021-04-21 10:41:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-23 13:30:45 +0000
commitbdf7ee008434d010d4fbb95390b22ff2d2271b37 (patch)
tree01c39ae4df2c22ba02df3237dd4f4e61ae8015e0 /src/mongo
parentb95494949b10daac02ae9c0da2d492d2e3294f6e (diff)
downloadmongo-bdf7ee008434d010d4fbb95390b22ff2d2271b37.tar.gz
SERVER-55059 Move fast-path of ExpressionContext::checkForInterrupt inline
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/pipeline/expression_context.cpp10
-rw-r--r--src/mongo/db/pipeline/expression_context.h10
2 files changed, 13 insertions, 7 deletions
diff --git a/src/mongo/db/pipeline/expression_context.cpp b/src/mongo/db/pipeline/expression_context.cpp
index 3dcc420e976..d63c9f4962a 100644
--- a/src/mongo/db/pipeline/expression_context.cpp
+++ b/src/mongo/db/pipeline/expression_context.cpp
@@ -157,13 +157,11 @@ ExpressionContext::ExpressionContext(
variables.seedVariablesWithLetParameters(this, *letParameters);
}
-void ExpressionContext::checkForInterrupt() {
+void ExpressionContext::checkForInterruptSlow() {
// This check could be expensive, at least in relative terms, so don't check every time.
- if (--_interruptCounter == 0) {
- invariant(opCtx);
- _interruptCounter = kInterruptCheckPeriod;
- opCtx->checkForInterrupt();
- }
+ invariant(opCtx);
+ _interruptCounter = kInterruptCheckPeriod;
+ opCtx->checkForInterrupt();
}
ExpressionContext::CollatorStash::CollatorStash(ExpressionContext* const expCtx,
diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h
index 8e2be4cdb2b..e75983b93b1 100644
--- a/src/mongo/db/pipeline/expression_context.h
+++ b/src/mongo/db/pipeline/expression_context.h
@@ -150,7 +150,11 @@ public:
* Used by a pipeline to check for interrupts so that killOp() works. Throws a UserAssertion if
* this aggregation pipeline has been interrupted.
*/
- void checkForInterrupt();
+ void checkForInterrupt() {
+ if (--_interruptCounter == 0) {
+ checkForInterruptSlow();
+ }
+ }
/**
* Returns true if this is a collectionless aggregation on the specified database.
@@ -379,6 +383,10 @@ protected:
friend class CollatorStash;
+ // Performs the heavy work of checking whether an interrupt has occurred. Should only be called
+ // when _interruptCounter has been decremented to zero.
+ void checkForInterruptSlow();
+
// Collator used for comparisons.
std::unique_ptr<CollatorInterface> _collator;