[MDEV-30289] mtr_t::m_memo is causing frequent memory heap operations Created: 2022-12-21 Updated: 2023-01-24 Resolved: 2023-01-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 11.0.0 |
| Fix Version/s: | 10.11.2, 11.0.1, 10.6.12, 10.7.8, 10.8.7, 10.9.5, 10.10.3 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | performance, regression | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
As part of fixing
Ideally, we would want to use a collection that implements something similar to the "small string optimization" of std::string. That is, we should allocate some memory for small mtr_t::m_memo as part of m_mtr itself. Only if too many objects are being latched in the mini-transaction (say, when very deep index trees are being accessed) we should need heap-based allocation. LLVM includes SmallVector, which is exactly what we would seem to need. It is also available in Boost as small_vector. |
| Comments |
| Comment by Marko Mäkelä [ 2022-12-22 ] | ||||||||||||||||||||
|
I ran some simple performance tests. Removing the pointer indirection for mtr_t::m_memo will not affect throughput much. Basically, it will only move the malloc() and free() calls from some member functions of mtr_t to the constructor and destructor. Almost every user of mtr_t will also use mtr_t::m_memo. Furthermore, I tested a port of llvm::SmallVector with two preallocated sizes.
As we can see, a fixed allocation of 8 elements does not make a difference to the throughput (transactions per second) in this simple benchmark, but 16 does. This was Sysbench oltp_update_index with 8×100,000 rows, on RAM disk, run for 120 seconds for each number of concurrent connections. In the refactoring that is needed for fixing | ||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-01-24 ] | ||||||||||||||||||||
|
A substantial part of |