[SERVER-80290] Change WiredTigerUtil::exportTableToBSON to use StringMap Created: 21/Aug/23  Updated: 24/Jan/24  Resolved: 04/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Task Priority: Minor - P4
Reporter: Mark Benvenuto Assignee: Brad Cater
Resolution: Fixed Votes: 0
Labels: perf-tiger, perf-tiger-handoff, perf-tiger-non-q4, perf-tiger-project-candidates, perf-tiger-triaged, storex-ranked
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes SERVER-85636 Poor FTDC compression due to apparent... Closed
Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2024-01-08
Participants:
Linked BF Score: 35

 Description   

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();
 }



 Comments   
Comment by Githook User [ 24/Jan/24 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: Revert "SERVER-80290 Change a std::map with string keys to a StringMap. (#17780)"

This reverts commit ecb1c5958e7d4848458801da9447658feb602050.

GitOrigin-RevId: 48f9bc89b4934a3de408c3b3cd6010da9c667e01
Branch: master
https://github.com/mongodb/mongo/commit/4fce8a8f977b9b012f8d049b86569bd2949c668e

Comment by Githook User [ 24/Jan/24 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: Revert "SERVER-80290 Change a std::map with string keys to a StringMap. (#17780)"

This reverts commit ecb1c5958e7d4848458801da9447658feb602050.

GitOrigin-RevId: fccad8f470cbba7266b98fb6b28c406abe36361b
Branch: v7.3
https://github.com/mongodb/mongo/commit/b17a9401cdbbb34aea90a4d879ab16addac9d587

Comment by Githook User [ 03/Jan/24 ]

Author:

{'name': 'Brad Cater', 'email': '152920274+brad-cater-mongodb@users.noreply.github.com', 'username': 'brad-cater-mongodb'}

Message: SERVER-80290 Change a std::map with string keys to a StringMap. (#17780)

GitOrigin-RevId: ecb1c5958e7d4848458801da9447658feb602050
Branch: master
https://github.com/mongodb/mongo/commit/296a76ac3169ef121e40ad82534324f2d43a5385

Generated at Thu Feb 08 06:43:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.