diff options
author | Clarisse Cheah <clarisse.cheah@mongodb.com> | 2023-04-03 00:59:20 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-03 01:35:55 +0000 |
commit | ad26950defa2a4a60c89839ec4a9302e569c70e5 (patch) | |
tree | 6e8aae68998b5b21f40a1a1497ae09383217584c /src | |
parent | f7d3a6583e1c1920cba00e56bb22889546f5b524 (diff) | |
download | mongo-ad26950defa2a4a60c89839ec4a9302e569c70e5.tar.gz |
Import wiredtiger: 5eb8f7e980fb5323d007ce1b7ec3cefa63751797 from branch mongodb-master
ref: 0d9fc80125..5eb8f7e980
for: 7.0.0-rc0
WT-10825 Allow shared operations to use different tables in Workgen
Diffstat (limited to 'src')
4 files changed, 60 insertions, 28 deletions
diff --git a/src/third_party/wiredtiger/bench/workgen/workgen.cpp b/src/third_party/wiredtiger/bench/workgen/workgen.cpp index a116a5e72b9..5bbf2f450d6 100644 --- a/src/third_party/wiredtiger/bench/workgen/workgen.cpp +++ b/src/third_party/wiredtiger/bench/workgen/workgen.cpp @@ -1374,6 +1374,11 @@ ThreadRunner::op_create_all(Operation *op, size_t &keysize, size_t &valuesize) else usage_flags |= ThreadRunner::USAGE_WRITE; _table_usage[op->_table._internal->_tint] = usage_flags; + } else { + // Set size of vector storing thread-to-table mappings for the operation. + if (op->_tables.size() != _wrunner->_trunners.size()) { + op->_tables.assign(_wrunner->_trunners.size(), std::string()); + } } } if (op->_group != nullptr) @@ -1426,23 +1431,53 @@ ThreadRunner::op_get_key_recno(Operation *op, uint64_t range, tint_t tint) return (rval % recno_count + 1); // recnos are one-based. } -// Clear the table uri and tint value for a dynamic table operation. +// This runner's thread completed the operation and is no longer using the assigned +// dynamic table. Remove the (thread,table) map entry for the operation. void ThreadRunner::op_clear_table(Operation *op) { - if (op->_random_table && op->is_table_op()) { - op->_table._uri = std::string(); - op->_table._internal->_tint = 0; + op->_tables[_number] = std::string(); +} + +// Get the uri and tint for the table assigned to the specified operation for this +// runner's thread. +std::tuple<std::string, tint_t> +ThreadRunner::op_get_table(Operation *op) const +{ + if (!op->_random_table) { + return {op->_table._uri, op->_table._internal->_tint}; + } + + std::string uri = op->_tables[_number]; + tint_t tint = 0; + if (uri != std::string()) { + const std::shared_lock lock(*_icontext->_dyn_mutex); + tint = _icontext->_dyn_tint[uri]; + } + return {uri, tint}; +} + +/* + * Check if the specified operation has an assigned table. For static tables, this information is + * saved in the Operation structure. For dynamic tables, the operation maintains a table assignment + * for each thread running the operation. + */ +bool +ThreadRunner::op_has_table(Operation *op) const +{ + if (op->_random_table) { + return (!op->_tables[_number].empty()); + } else { + return (!op->_table._uri.empty()); } } -// Set the table uri and tint value for a dynamic table operation. +// Set the table uri for the thread running this operation. Used for dynamic table operations. void -ThreadRunner::op_set_table(Operation *op, const std::string &uri, const tint_t tint) +ThreadRunner::op_set_table(Operation *op, const std::string &uri) { - if (op->_random_table && op->is_table_op()) { - op->_table._uri = uri; - op->_table._internal->_tint = tint; + if (op->_random_table) { + op->_tables[_number] = uri; } } @@ -1521,9 +1556,9 @@ ThreadRunner::op_run_setup(Operation *op) return op_run(op); } - // If this is not a dynamic table operation, we still need to generate keys and values. - if (op->has_table()) { - // Mirrored tables don't need key nor value here. + // If the operation already has a table, it's ready to run. + if (op_has_table(op)) { + // If this is not a dynamic table operation, we need to generate keys and values. if (!op->_random_table) { tint_t tint = op->_table._internal->_tint; op_kv_gen(op, tint); @@ -1541,7 +1576,7 @@ ThreadRunner::op_run_setup(Operation *op) // Select a random base table that is not flagged for deletion. std::map<std::string, tint_t>::iterator itr; uint32_t retries = 0; - size_t num_tables; + size_t num_tables = 0; while ( (num_tables = _icontext->_dyn_table_names.size()) > 0 && ++retries < TABLE_MAX_RETRIES) { @@ -1566,18 +1601,18 @@ ThreadRunner::op_run_setup(Operation *op) // Do we need to mirror operations? If not, we are done here. if (!_icontext->_dyn_table_runtime[op_tint].has_mirror()) { - op_set_table(op, op_uri, op_tint); + op_set_table(op, op_uri); return op_run(op); } // Copy this operation to two new operations on the base table and the mirror. base_op = *op; - op_set_table(&base_op, op_uri, op_tint); + op_set_table(&base_op, op_uri); mirror_op = *op; std::string mirror_op_uri = _icontext->_dyn_table_runtime[op_tint]._mirror; tint_t mirror_op_tint = _icontext->_dyn_tint[mirror_op_uri]; - op_set_table(&mirror_op, mirror_op_uri, mirror_op_tint); + op_set_table(&mirror_op, mirror_op_uri); (void)workgen_atomic_add32(&_icontext->_dyn_table_runtime[mirror_op_tint]._in_use, 1); ASSERT(!_icontext->_dyn_table_runtime[mirror_op_tint]._pending_delete); } @@ -1608,8 +1643,7 @@ ThreadRunner::op_run(Operation *op) timespec start_time; uint64_t time_us; char buf[BUF_SIZE]; - std::string table_uri = op->_table._uri; - tint_t tint = op->_table._internal->_tint; + auto [table_uri, tint] = op_get_table(op); WT_CLEAR(item); track = nullptr; @@ -2041,7 +2075,7 @@ Operation::Operation(const Operation &other) : _optype(other._optype), _internal(nullptr), _table(other._table), _key(other._key), _value(other._value), _config(other._config), transaction(other.transaction), _group(other._group), _repeatgroup(other._repeatgroup), _timed(other._timed), - _random_table(other._random_table) + _random_table(other._random_table), _tables(other._tables) { // Creation and destruction of _group and transaction is managed // by Python. @@ -2073,6 +2107,7 @@ Operation::operator=(const Operation &other) _repeatgroup = other._repeatgroup; _timed = other._timed; _random_table = other._random_table; + _tables = other._tables; delete _internal; _internal = nullptr; init_internal(other._internal); @@ -2204,12 +2239,6 @@ Operation::get_static_counts(Stats &stats, int multiplier) } bool -Operation::has_table() const -{ - return (!_table._uri.empty()); -} - -bool Operation::is_table_op() const { return ( diff --git a/src/third_party/wiredtiger/bench/workgen/workgen.h b/src/third_party/wiredtiger/bench/workgen/workgen.h index f978af3ce80..16f8f774400 100644 --- a/src/third_party/wiredtiger/bench/workgen/workgen.h +++ b/src/third_party/wiredtiger/bench/workgen/workgen.h @@ -302,6 +302,8 @@ struct Operation { double _timed; // Indicates whether a table is selected randomly to be worked on. bool _random_table; + // Maintain the random table being used by each thread running the operation. + std::vector<std::string> _tables; Operation(); Operation(OpType optype, Table table, Key key, Value value); @@ -323,7 +325,6 @@ struct Operation { void init_internal(OperationInternal *other); void create_all(); void get_static_counts(Stats &stats, int multiplier); - bool has_table() const; bool is_table_op() const; void kv_compute_max(bool iskey, bool has_random); void kv_gen(ThreadRunner *runner, bool iskey, uint64_t compressibility, diff --git a/src/third_party/wiredtiger/bench/workgen/workgen_int.h b/src/third_party/wiredtiger/bench/workgen/workgen_int.h index 23472e2d785..d8ef4f65d4a 100644 --- a/src/third_party/wiredtiger/bench/workgen/workgen_int.h +++ b/src/third_party/wiredtiger/bench/workgen/workgen_int.h @@ -162,10 +162,12 @@ struct ThreadRunner { void op_create_all(Operation *, size_t &keysize, size_t &valuesize); uint64_t op_get_key_recno(Operation *, uint64_t range, tint_t tint); void op_get_static_counts(Operation *, Stats &, int); + std::tuple<std::string, tint_t> op_get_table(Operation *op) const; + bool op_has_table(Operation *op) const; void op_kv_gen(Operation *op, const tint_t tint); int op_run(Operation *); int op_run_setup(Operation *); - void op_set_table(Operation *op, const std::string &uri, const tint_t tint); + void op_set_table(Operation *op, const std::string &uri); float random_signed(); uint32_t random_value(); diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 8508e1b8f21..b94a00caf2a 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-master", - "commit": "0d9fc801258a1da0b3e76c8c39cd50a8e20eff96" + "commit": "5eb8f7e980fb5323d007ce1b7ec3cefa63751797" } |