-
Type: Task
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Storage Execution
-
Fully Compatible
-
Execution Team 2024-01-08
-
35
WiredTigerUtil::exportTableToBSON uses std::map<string, BSONObjBuilder> which causes a lot of unnecessary temporary string allocations to lookup values.
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp @@ -1120,7 +1121,7 @@ Status WiredTigerUtil::exportTableToBSON(WT_SESSION* session, invariant(c); ON_BLOCK_EXIT([&] { c->close(c); }); - std::map<string, BSONObjBuilder*> subs; + StringMap<BSONObjBuilder*> subs; const char* desc; uint64_t value; while (c->next(c) == 0 && c->get_value(c, &desc, nullptr, &value) == 0) { @@ -1155,18 +1156,17 @@ Status WiredTigerUtil::exportTableToBSON(WT_SESSION* session, continue; } - BSONObjBuilder*& sub = subs[prefix.toString()]; + BSONObjBuilder*& sub = subs[prefix]; if (!sub) sub = new BSONObjBuilder(); - sub->appendNumber(str::ltrim(suffix.toString()), v); + sub->appendNumber(str::ltrim(suffix), v); } } - for (std::map<string, BSONObjBuilder*>::const_iterator it = subs.begin(); it != subs.end(); - ++it) { - const std::string& s = it->first; - bob->append(s, it->second->obj()); - delete it->second; + for (const auto &kvp : subs ) { + const std::string& s = kvp.first; + bob->append(s, kvp.second->obj()); + // delete it->second; } return Status::OK(); }
- causes
-
SERVER-85636 Poor FTDC compression due to apparent schema change observed on 7.3.0-alpha1
- Closed
- is related to
-
SERVER-88491 Avoid unnecessary allocations in WiredTigerUtil::exportTableToBSON
- Closed