Skip to content

Commit

Permalink
PS-9378: Backport PS-9302 (WRITESET perf improvements) to 8.0
Browse files Browse the repository at this point in the history
https://perconadev.atlassian.net/browse/PS-9378

Cherry-piked 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.
  • Loading branch information
kamil-holubicki authored and percona-ysorokin committed Sep 6, 2024
1 parent 646a7cf commit d87bd64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sql/rpl_trx_tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <assert.h>
#include <sys/types.h>
#include <atomic>
#include <map>
#include <unordered_map>

#include "libbinlogevents/include/binlog_event.h"

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

Expand Down

0 comments on commit d87bd64

Please sign in to comment.