summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2023-03-16 13:47:41 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-16 14:36:12 +0000
commit781a833548ce9b1c4a92bd1b09be405ef4e02935 (patch)
treef40e17aaf96c0fa4a4c69e1964d3520b01494b29 /src/mongo/db
parent80caaf6c05cc0a9bb5f5e0458c671ba7ffd528b5 (diff)
downloadmongo-781a833548ce9b1c4a92bd1b09be405ef4e02935.tar.gz
SERVER-74569 Start with number of CPU cores for throughput probing
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/concurrency/d_concurrency_test.cpp2
-rw-r--r--src/mongo/db/storage/SConscript1
-rw-r--r--src/mongo/db/storage/execution_control/throughput_probing.cpp10
-rw-r--r--src/mongo/db/storage/execution_control/throughput_probing.idl12
-rw-r--r--src/mongo/db/storage/execution_control/throughput_probing_test.cpp10
5 files changed, 30 insertions, 5 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp
index ba3a3ada084..dc5790cb65f 100644
--- a/src/mongo/db/concurrency/d_concurrency_test.cpp
+++ b/src/mongo/db/concurrency/d_concurrency_test.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/concurrency/replication_state_transition_lock_guard.h"
#include "mongo/db/service_context_d_test_fixture.h"
#include "mongo/db/storage/recovery_unit_noop.h"
+#include "mongo/db/storage/storage_engine_parameters_gen.h"
#include "mongo/db/storage/ticketholder_manager.h"
#include "mongo/logv2/log.h"
#include "mongo/stdx/future.h"
@@ -71,6 +72,7 @@ class UseReaderWriterGlobalThrottling {
public:
explicit UseReaderWriterGlobalThrottling(ServiceContext* svcCtx, int numTickets)
: _svcCtx(svcCtx) {
+ gStorageEngineConcurrencyAdjustmentAlgorithm = "";
// TODO SERVER-72616: Remove ifdefs once PriorityTicketHolder is available cross-platform.
#ifdef __linux__
if constexpr (std::is_same_v<PriorityTicketHolder, TicketHolderImpl>) {
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index 19547976e7a..b7258d7da1c 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -218,6 +218,7 @@ env.Library(
'$BUILD_DIR/mongo/db/server_base',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/util/concurrency/ticketholder',
+ '$BUILD_DIR/mongo/util/processinfo',
'storage_engine_feature_flags',
],
)
diff --git a/src/mongo/db/storage/execution_control/throughput_probing.cpp b/src/mongo/db/storage/execution_control/throughput_probing.cpp
index 5087318776a..58040618713 100644
--- a/src/mongo/db/storage/execution_control/throughput_probing.cpp
+++ b/src/mongo/db/storage/execution_control/throughput_probing.cpp
@@ -30,6 +30,7 @@
#include "mongo/db/storage/execution_control/throughput_probing.h"
#include "mongo/db/storage/execution_control/throughput_probing_gen.h"
#include "mongo/logv2/log.h"
+#include "mongo/util/processinfo.h"
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kStorage
@@ -40,7 +41,14 @@ ThroughputProbing::ThroughputProbing(ServiceContext* svcCtx,
TicketHolder* writeTicketHolder,
Milliseconds interval)
: TicketHolderMonitor(svcCtx, readTicketHolder, writeTicketHolder, interval),
- _stableConcurrency(_readTicketHolder->outof()) {}
+ _stableConcurrency(throughput_probing::gInitialConcurrency
+ ? throughput_probing::gInitialConcurrency
+ : std::clamp(static_cast<int32_t>(ProcessInfo::getNumCores()),
+ kMinConcurrency,
+ kMaxConcurrency)) {
+ _readTicketHolder->resize(_stableConcurrency);
+ _writeTicketHolder->resize(_stableConcurrency);
+}
void ThroughputProbing::appendStats(BSONObjBuilder& builder) const {
_stats.serialize(builder);
diff --git a/src/mongo/db/storage/execution_control/throughput_probing.idl b/src/mongo/db/storage/execution_control/throughput_probing.idl
index 68a7ad559c5..f4418f6083e 100644
--- a/src/mongo/db/storage/execution_control/throughput_probing.idl
+++ b/src/mongo/db/storage/execution_control/throughput_probing.idl
@@ -38,3 +38,15 @@ server_parameters:
validator:
gte: 0.1
lte: 0.5
+
+ throughputProbingInitialConcurrency:
+ description: >-
+ The initial number of concurrent read/write transactions for throughput probing. The default
+ value of 0 means to use the number of logical CPU cores.
+ set_at: startup
+ cpp_vartype: int32_t
+ cpp_varname: gInitialConcurrency
+ default: 0
+ validator:
+ gte: 5
+ lte: 128
diff --git a/src/mongo/db/storage/execution_control/throughput_probing_test.cpp b/src/mongo/db/storage/execution_control/throughput_probing_test.cpp
index 340cb616b5a..d2da4844ea9 100644
--- a/src/mongo/db/storage/execution_control/throughput_probing_test.cpp
+++ b/src/mongo/db/storage/execution_control/throughput_probing_test.cpp
@@ -28,6 +28,7 @@
*/
#include "mongo/db/storage/execution_control/throughput_probing.h"
+#include "mongo/db/storage/execution_control/throughput_probing_gen.h"
#include "mongo/unittest/unittest.h"
namespace mongo::execution_control {
@@ -85,8 +86,10 @@ protected:
svcCtx->setPeriodicRunner(std::move(runner));
return runnerPtr;
}()),
- _readTicketHolder(size),
- _writeTicketHolder(size) {}
+ _throughputProbing([&]() -> ThroughputProbing {
+ throughput_probing::gInitialConcurrency = size;
+ return {_svcCtx.get(), &_readTicketHolder, &_writeTicketHolder, Milliseconds{1}};
+ }()) {}
void _run() {
_runner->run(_client.get());
@@ -99,8 +102,7 @@ protected:
MockTicketHolder _readTicketHolder;
MockTicketHolder _writeTicketHolder;
- ThroughputProbing _througputProbing{
- _svcCtx.get(), &_readTicketHolder, &_writeTicketHolder, Milliseconds{1}};
+ ThroughputProbing _throughputProbing;
};
class ThroughputProbingMaxConcurrencyTest : public ThroughputProbingTest {