Skip to content

Commit 40d7e5a

Browse files
kamil-holubickipercona-ysorokin
authored andcommitted
PS-9378: Backport PS-9302 (WRITESET perf improvements) to 8.0
https://perconadev.atlassian.net/browse/PS-9378 This patch was originally created for the 8.4 branch where the only available binlog transaction dependency tracking mode is 'WRITESET'. However, it also makes sense to backport this to 8.0 as the same code paths are used when user explicitly set the 'binlog_transaction_dependency_tracking' system variable to 'WRITESET' (by default in 8.0 series, this variable is set to 'COMMIT_ORDER'). Cherry-picked PS-9302 "Improve performance for binlog_transaction_dependency_tracking=WRITESET" (https://perconadev.atlassian.net/browse/PS-9302) from 8.4. Problem: Comparing to 8.0 where the default value of binlog_transaction_dependency_tracking was COMMIT_ORDER, 8.4 introduces a visible write performance drop. Cause: 8.4 uses WRITESET dependency tracking. For this tracking we maintain a map of binlog_transaction_dependency_history_size for row_id to newest transaction sequence_number which modified a given row. Every new transaction needs to check its dependency by examining the map (find), which is done with logarithmic complexity. Solution: Change std::map to std::unordered_map. This allows us to find a row dependency in constant on average complexity.
1 parent 646a7cf commit 40d7e5a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql/rpl_trx_tracking.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <assert.h>
2828
#include <sys/types.h>
2929
#include <atomic>
30-
#include <map>
30+
#include <unordered_map>
3131

3232
#include "libbinlogevents/include/binlog_event.h"
3333

@@ -157,7 +157,7 @@ class Writeset_trx_dependency_tracker {
157157
Track the last transaction sequence number that changed each row
158158
in the database, using row hashes from the writeset as the index.
159159
*/
160-
typedef std::map<uint64, int64> Writeset_history;
160+
typedef std::unordered_map<uint64, int64> Writeset_history;
161161
Writeset_history m_writeset_history;
162162
};
163163

0 commit comments

Comments
 (0)