summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/flow_control.h
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-04-26 09:41:14 -0400
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-04-26 09:41:14 -0400
commit520c56ca5a94dcd44d01a69ebaafd34307473df8 (patch)
tree9284aea487dfb5e4e26f6258fbb64d1b04c8ed58 /src/mongo/db/storage/flow_control.h
parent3121bdb9f80399dc542c145c231f51d325c0b869 (diff)
downloadmongo-520c56ca5a94dcd44d01a69ebaafd34307473df8.tar.gz
SERVER-39616: Throw away flow control samples when the majority point stands still.
Diffstat (limited to 'src/mongo/db/storage/flow_control.h')
-rw-r--r--src/mongo/db/storage/flow_control.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/mongo/db/storage/flow_control.h b/src/mongo/db/storage/flow_control.h
index 4f111ee645a..2261778547d 100644
--- a/src/mongo/db/storage/flow_control.h
+++ b/src/mongo/db/storage/flow_control.h
@@ -29,6 +29,8 @@
#pragma once
+#include <deque>
+
#include "mongo/db/commands/server_status.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/service_context.h"
@@ -79,29 +81,40 @@ public:
const BSONElement& configElement) const override;
private:
- int64_t getLocksUsedLastPeriod();
+ std::int64_t _getLocksUsedLastPeriod();
+ double _getLocksPerOp();
+
+ std::int64_t _approximateOpsBetween(Timestamp prevTs, Timestamp currTs);
- std::int64_t _approximateOpsBetween(std::uint64_t prevTs, std::uint64_t currTs);
- double _getMyLocksPerOp();
+ void _updateTopologyData();
+ int _calculateNewTicketsForLag(const std::vector<repl::MemberData>& prevMemberData,
+ const std::vector<repl::MemberData>& currMemberData,
+ std::int64_t locksUsedLastPeriod,
+ double locksPerOp);
+ void _trimSamples(const Timestamp trimSamplesTo);
repl::ReplicationCoordinator* _replCoord;
- AtomicWord<int> _lastTargetTicketsPermitted;
- AtomicWord<double> _lastLocksPerOp;
- AtomicWord<int> _lastSustainerAppliedCount;
+ // These values are updated with each flow control computation that are also surfaced in server
+ // status.
+ AtomicWord<int> _lastTargetTicketsPermitted{0};
+ AtomicWord<double> _lastLocksPerOp{0.0};
+ AtomicWord<int> _lastSustainerAppliedCount{0};
mutable stdx::mutex _sampledOpsMutex;
// Sample of (timestamp, ops, lock acquisitions) where ops and lock acquisitions are
// observations of the corresponding counter at (roughly) <timestamp>.
typedef std::tuple<std::uint64_t, std::uint64_t, std::int64_t> Sample;
- std::vector<Sample> _sampledOpsApplied;
- std::int64_t _lastPollLockAcquisitions = 0;
+ std::deque<Sample> _sampledOpsApplied;
+
+ // These values are used in the sampling process.
std::uint64_t _numOpsSinceStartup = 0;
std::uint64_t _lastSample = 0;
- std::vector<repl::MemberData> _prevMemberData;
+ std::int64_t _lastPollLockAcquisitions = 0;
- long long _prevLagMillis = 0;
+ std::vector<repl::MemberData> _currMemberData;
+ std::vector<repl::MemberData> _prevMemberData;
};
} // namespace mongo