diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2015-11-19 10:19:50 -0500 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2015-11-19 10:19:50 -0500 |
commit | 721048cbc4e6b7d250cd729967b94e244426156d (patch) | |
tree | 55ec7d69750070a9f14adc4d2a454a631d8563fb /jstests/concurrency | |
parent | 7b5e0e00ae7f5df3a0bb07a22fbc886ee36da9ca (diff) | |
download | mongo-721048cbc4e6b7d250cd729967b94e244426156d.tar.gz |
SERVER-21522 Make a copy of the $config before running a workload.
Mutating the "threadCount" property in the ThreadManager is now safe
because subsequent executions of a workload group in the schedule will
use fresh $config objects. The proportion of workloads within the group
will be based off the number of threads initially requested, even if a
previous workload needed to be scaled down.
Diffstat (limited to 'jstests/concurrency')
-rw-r--r-- | jstests/concurrency/fsm_libs/runner.js | 12 | ||||
-rw-r--r-- | jstests/concurrency/fsm_libs/thread_mgr.js | 19 |
2 files changed, 18 insertions, 13 deletions
diff --git a/jstests/concurrency/fsm_libs/runner.js b/jstests/concurrency/fsm_libs/runner.js index cfe61369d8a..b19435d8619 100644 --- a/jstests/concurrency/fsm_libs/runner.js +++ b/jstests/concurrency/fsm_libs/runner.js @@ -593,8 +593,18 @@ var runner = (function() { throw new IterationEnd(msg); } + // Make a deep copy of the $config object for each of the workloads that are + // going to be run to ensure the workload starts with a fresh version of its + // $config.data. This is necessary because $config.data keeps track of + // thread-local state that may be updated during a workload's setup(), + // teardown(), and state functions. + var groupContext = {}; + workloads.forEach(function(workload) { + groupContext[workload] = Object.extend({}, context[workload], true); + }); + // Run the next group of workloads in the schedule. - runWorkloadGroup(threadMgr, workloads, context, cluster, clusterOptions, + runWorkloadGroup(threadMgr, workloads, groupContext, cluster, clusterOptions, executionMode, executionOptions, errors, maxAllowedThreads); }); } finally { diff --git a/jstests/concurrency/fsm_libs/thread_mgr.js b/jstests/concurrency/fsm_libs/thread_mgr.js index 695a4420e7c..d2a1cb99243 100644 --- a/jstests/concurrency/fsm_libs/thread_mgr.js +++ b/jstests/concurrency/fsm_libs/thread_mgr.js @@ -42,7 +42,6 @@ var ThreadManager = function(clusterOptions, executionMode) { var initialized = false; var threads = []; - var threadCounts = {}; var _workloads, _context; @@ -59,25 +58,21 @@ var ThreadManager = function(clusterOptions, executionMode) { return 0; } return Array.sum(workloads.map(function(workload) { - return threadCounts[workload]; + return context[workload].config.threadCount; })); } - workloads.forEach(function(workload) { - var config = context[workload].config; - threadCounts[workload] = config.threadCount; - }); - var requestedNumThreads = computeNumThreads(); if (requestedNumThreads > maxAllowedThreads) { // Scale down the requested '$config.threadCount' values to make // them sum to less than 'maxAllowedThreads' var factor = maxAllowedThreads / requestedNumThreads; workloads.forEach(function(workload) { - var threadCount = threadCounts[workload]; + var config = context[workload].config; + var threadCount = config.threadCount; threadCount = Math.floor(factor * threadCount); threadCount = Math.max(1, threadCount); // ensure workload is executed - threadCounts[workload] = threadCount; + config.threadCount = threadCount; }); } @@ -104,13 +99,14 @@ var ThreadManager = function(clusterOptions, executionMode) { var workloadData = {}; var tid = 0; _workloads.forEach(function(workload) { - workloadData[workload] = _context[workload].config.data; + var config = _context[workload].config; + workloadData[workload] = config.data; var workloads = [workload]; // worker thread only needs to load 'workload' if (executionMode.composed) { workloads = _workloads; // worker thread needs to load all workloads } - for (var i = 0; i < threadCounts[workload]; ++i) { + for (var i = 0; i < config.threadCount; ++i) { var args = { tid: tid++, data: workloadData, @@ -188,7 +184,6 @@ var ThreadManager = function(clusterOptions, executionMode) { initialized = false; threads = []; - threadCounts = {}; return errors; }; |