morningman commented on a change in pull request #3222: Support sharding 
txn_map_lock into more small map locks to make good performance for txn manage 
task
URL: https://github.com/apache/incubator-doris/pull/3222#discussion_r400932172
 
 

 ##########
 File path: be/src/olap/txn_manager.h
 ##########
 @@ -140,30 +141,48 @@ class TxnManager {
     void get_partition_ids(const TTransactionId transaction_id, 
std::vector<TPartitionId>* partition_ids);
     
 private:
-    RWMutex* _get_txn_lock(TTransactionId txn_id) {
-        return _txn_locks[txn_id % _txn_lock_num].get();
-    }
+
+    using TxnKey = std::pair<int64_t, int64_t>; // partition_id, 
transaction_id;
+
+    typedef std::map<TxnKey, std::map<TabletInfo, TabletTxnInfo>> 
txn_tablet_map_t;
+    typedef std::unordered_map<int64_t, std::unordered_set<int64_t>> 
txn_partition_map_t;
+
+    inline RWMutex& _get_txn_map_lock(TTransactionId transactionId);
+
+    inline txn_tablet_map_t& _get_txn_tablet_map(TTransactionId transactionId);
+
+    inline txn_partition_map_t& _get_txn_partition_map(TTransactionId 
transactionId);
 
     // insert or remove (transaction_id, partition_id) from _txn_partition_map
     // get _txn_map_lock before calling
     void _insert_txn_partition_map_unlocked(int64_t transaction_id, int64_t 
partition_id);
     void _clear_txn_partition_map_unlocked(int64_t transaction_id, int64_t 
partition_id);
 
 private:
-    RWMutex _txn_map_lock;
-    using TxnKey = std::pair<int64_t, int64_t>; // partition_id, 
transaction_id;
-    std::map<TxnKey, std::map<TabletInfo, TabletTxnInfo>> _txn_tablet_map;
+    const int32_t _txn_map_shard_size;
+
+    // _txn_map_locks[i] protect _txn_tablet_maps[i], i=0,1,2...,and i < 
_txn_map_shard_size
+    std::map<TxnKey, std::map<TabletInfo, TabletTxnInfo>> *_txn_tablet_maps;
 
 Review comment:
   ```suggestion
       txn_tablet_map_t *_txn_tablet_maps;
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to