@@ -14,85 +14,94 @@ box.stat.memtx()
14
14
box.stat.memtx().tx
15
15
-------------------
16
16
17
- * ``tx `` shows the statistics of the memtx transactional manager,
18
- which is responsible for transactions (``box.stat.memtx().tx.txn ``)
19
- and multiversion concurrency control (``box.stat.memtx().tx.mvcc ``).
20
-
21
- * ``box.stat.memtx().tx.txn `` shows memory allocation related to transactions.
22
-
23
- It consists of the following sections:
24
-
25
- * ``statements `` are *transaction statements *.
26
- As an example, consider a user starting a transaction with
27
- ``space:replace{0, 1} `` within this transaction. Under the hood,
28
- this operation becomes a statement for this transaction.
29
- * ``user `` is the memory that a user allocated within
30
- the current transaction using the Tarantool C API function
31
- :ref: `box_txn_alloc() <txn-box_txn_alloc >`.
32
- * ``system `` is the memory allocated for internal needs
33
- (for example, logs) and savepoints.
34
-
35
- For each section, Tarantool reports the following statistics:
36
-
37
- * ``total `` is the number of bytes that are currently allocated in memtx
38
- for all transactions within the section scope.
39
- * ``avg `` is the average number of bytes that a single transaction uses
40
- (equals ``total `` / number of open transactions).
41
- * ``max `` is the maximal number of bytes that a single transaction uses.
42
-
43
- * ``box.stat.memtx().tx.mvcc `` shows memory allocation related to
44
- :ref: `multiversion concurrency control (MVCC) <txn_mode_transaction-manager >`.
45
- MVCC is reponsible for isolating transactions.
46
- It reveals conflicts and makes sure that tuples that do not belong to a particular
47
- space but were (or could be) read by some transaction were not deleted.
48
-
49
- It consists of the following sections:
50
-
51
- * ``trackers `` is the memory allocated for *trackers * of transaction reads.
52
- Like in the previous sections, Tarantool reports the total, average
53
- and maximal number of bytes allocated for trackers per a single transaction.
54
- * ``conflicts `` is the memory allocated for *conflicts *
55
- which are entities created when transactional conflicts occur.
56
- Like in the previous sections, Tarantool reports the total, average
57
- and maximal number of allocated bytes.
58
- * ``tuples `` is the memory allocated for storing tuples.
59
- With MVCC, tuples are stored using the *stories * mechanism. Nearly every
60
- tuple has its story. Even tuples in an index may have their stories, so
61
- it may be useful to differentiate memory allocated for tuples and memory
62
- allocated for stories.
63
-
64
- All stored tuples fall into three categories, with memory statistics
65
- reported for each category:
66
-
67
- * ``tracking `` is for tuples that are not used by any transactions directly,
68
- but MVCC uses them for tracking transaction reads.
69
- * ``used `` is for tuples that are used by active read-write transactions.
70
- * ``read_view `` is for tuples that are not used by active read-write transactions,
71
- but are used by read-only transactions.
72
-
73
- For each of the three categories, Tarantool reports two statistical blocks:
74
-
75
- * ``stories `` is for stories.
76
- * ``retained `` is for *retained * tuples which do not belong to any index,
77
- but MVCC doesn't allow to delete them yet.
78
-
79
- For each block, Tarantool reports the following statistics:
80
-
81
- * ``count `` is the number of stories or retained tuples.
82
- * ``total `` is the number of bytes allocated for stories or retained tuples.
17
+ ``tx `` shows the statistics of the memtx transactional manager,
18
+ which is responsible for transactions (``box.stat.memtx().tx.txn ``)
19
+ and multiversion concurrency control (``box.stat.memtx().tx.mvcc ``).
20
+
21
+ * ``box.stat.memtx().tx.txn `` shows memory allocation related to transactions.
22
+
23
+ It consists of the following sections:
24
+
25
+ * ``statements `` are *transaction statements *.
26
+ As an example, consider a user starting a transaction with
27
+ ``space:replace{0, 1} `` within this transaction. Under the hood,
28
+ this operation becomes a statement for this transaction.
29
+ * ``user `` is the memory that a user allocated within
30
+ the current transaction using the Tarantool C API function
31
+ :ref: `box_txn_alloc() <txn-box_txn_alloc >`.
32
+ * ``system `` is the memory allocated for internal needs
33
+ (for example, logs) and savepoints.
34
+
35
+ .. _box_introspection-box_stat_memtx_tx_total_avg_max :
36
+
37
+ For each section, Tarantool reports the following statistics:
38
+
39
+ * ``total `` is the number of bytes that are currently allocated in memtx
40
+ for all transactions within the section scope.
41
+ * ``avg `` is the average number of bytes that a single transaction uses
42
+ (equals ``total `` / number of open transactions).
43
+ * ``max `` is the maximal number of bytes that a single transaction uses.
44
+
45
+ * ``box.stat.memtx().tx.mvcc `` shows memory allocation related to
46
+ :ref: `multiversion concurrency control (MVCC) <txn_mode_transaction-manager >`.
47
+ MVCC is reponsible for isolating transactions.
48
+ It reveals conflicts and makes sure that tuples that do not belong to a particular
49
+ space but were (or could be) read by some transaction were not deleted.
50
+
51
+ It consists of the following sections:
52
+
53
+ * ``trackers `` is the memory allocated for *trackers * of transaction reads.
54
+ Like in the :ref: `previous sections <box_introspection-box_stat_memtx_tx_total_avg_max >`,
55
+ Tarantool reports the total, average, and maximal number of bytes allocated
56
+ for trackers per a single transaction.
57
+ * ``conflicts `` is the memory allocated for *conflicts *
58
+ which are entities created when transactional conflicts occur.
59
+ Like in the :ref: `previous sections <box_introspection-box_stat_memtx_tx_total_avg_max >`,
60
+ Tarantool reports the total, average, and maximal number of allocated bytes.
61
+ * ``tuples `` is the memory allocated for storing tuples.
62
+ With MVCC, tuples are stored using the *stories * mechanism. Nearly every
63
+ tuple has its story. Even tuples in an index may have their stories, so
64
+ it may be useful to differentiate memory allocated for tuples and memory
65
+ allocated for stories.
66
+
67
+ All stored tuples fall into three categories, with memory statistics
68
+ reported for each category:
69
+
70
+ * ``tracking `` is for tuples that are not used by any transactions directly,
71
+ but MVCC uses them for tracking transaction reads.
72
+ * ``used `` is for tuples that are used by active read-write transactions.
73
+ See a detailed :ref: `example <box_introspection-box_stat_memtx_tx_example >` below.
74
+ * ``read_view `` is for tuples that are not used by active read-write transactions,
75
+ but are used by read-only transactions.
76
+
77
+ For each of the three categories, Tarantool reports two statistical blocks:
78
+
79
+ * ``stories `` is for stories.
80
+ * ``retained `` is for *retained * tuples which do not belong to any index,
81
+ but MVCC doesn't allow to delete them yet.
82
+
83
+ For each block, Tarantool reports the following statistics:
84
+
85
+ * ``count `` is the number of stories or retained tuples.
86
+ * ``total `` is the number of bytes allocated for stories or retained tuples.
87
+
88
+ .. _box_introspection-box_stat_memtx_tx_example :
83
89
84
90
**Example **
85
91
86
- Let's get memory statistics for `used ` tuples in a transaction.
92
+ Let's get memory statistics for `` used ` ` tuples in a transaction.
87
93
88
- To make transactions work , we need to :ref: `enable the MVCC engine <txn_mode_mvcc-enabling >`.
89
- We'll do it within the first ``box.cfg{} `` call to a new Tarantool instance:
94
+ First , we :ref: `enable MVCC <txn_mode_mvcc-enabling >` so that
95
+ ``box.stat.memtx.tx().mvcc `` contained non-zero values.
90
96
91
97
.. code-block :: lua
92
98
93
99
box.cfg{memtx_use_mvcc_engine = true}
94
100
95
- Next, we'll create a space with a primary index, and begin a transaction:
101
+ We did it within the first ``box.cfg{} `` call to a new Tarantool instance,
102
+ because the parameter ``memtx_use_mvcc_engine `` is non-dynamic.
103
+
104
+ Next, we create a space with a primary index, and begin a transaction:
96
105
97
106
.. code-block :: lua
98
107
@@ -112,8 +121,8 @@ In the transaction above, we replaced three tuples by the `0` key:
112
121
* ``{0, 'aa...aa'} ``
113
122
* ``{0, 1} ``
114
123
115
- MVCC considers all these tuples as `used ` since they belong to the current transaction.
116
- Meanwhile , MVCC considers tuples ``{0, 0} `` and ``{0, 'aa..aa'} `` as `retained ` because
124
+ MVCC considers all these tuples as `` used ` ` since they belong to the current transaction.
125
+ Also , MVCC considers tuples ``{0, 0} `` and ``{0, 'aa..aa'} `` as `` retained ` ` because
117
126
they don't belong to any index (unlike ``{0, 1} ``), but they cannot be deleted yet.
118
127
119
128
If we call ``box.stat.memtx.tx() `` now, we'll see something like this:
@@ -169,10 +178,4 @@ If we call ``box.stat.memtx.tx()`` now, we'll see something like this:
169
178
total: 0
170
179
...
171
180
172
- Pay attention to highlighted lines -- it's the memory used allocated for `used ` tuples.
173
-
174
- For a neat experiment, let's commit the transaction:
175
-
176
- .. code-block :: lua
177
-
178
- box.commit()
181
+ Pay attention to highlighted lines -- it's the memory allocated for `used ` tuples.
0 commit comments