Skip to content

Commit 217fea3

Browse files
committed
Add reference for box.stat.memtx().tx
1 parent 794f3bf commit 217fea3

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

doc/reference/reference_capi/txn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
4040
Roll back the current transaction as far as the specified savepoint.
4141
42+
.. _txn-box_txn_alloc:
43+
4244
.. c:function:: void *box_txn_alloc(size_t size)
4345
4446
Allocate memory on txn memory pool.

doc/reference/reference_lua/box_stat.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ Below is a list of all ``box.stat`` functions.
2626
* - :doc:`./box_stat/net`
2727
- Show network activity
2828

29+
* - :doc:`./box_stat/memtx`
30+
- Show memtx-storage-engine activity
31+
2932
* - :doc:`./box_stat/vinyl`
3033
- Show vinyl-storage-engine activity
3134

@@ -37,5 +40,6 @@ Below is a list of all ``box.stat`` functions.
3740

3841
box_stat/stat
3942
box_stat/net
43+
box_stat/memtx
4044
box_stat/vinyl
41-
box_stat/reset
45+
box_stat/reset
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.. _box_introspection-box_stat_memtx:
2+
3+
box.stat.memtx()
4+
================
5+
6+
.. module:: box.stat
7+
8+
.. function:: memtx()
9+
10+
Shows memtx-storage-engine activity.
11+
12+
.. _box_introspection-box_stat_memtx_tx:
13+
14+
box.stat.memtx().tx
15+
-------------------
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+
* ``box.stat.memtx().tx.txn.statements`` are *transaction statements*.
24+
As an example, consider a user starting a transaction with
25+
``space:replace{0, 1}`` within this transaction. Under the hood,
26+
this operation becomes a statement for this transaction.
27+
Tarantool reports the following statistics for statements:
28+
* ``box.stat.memtx().tx.txn.statements.max`` is the maximal number of bytes
29+
that a single transaction uses for statements.
30+
* ``box.stat.memtx().tx.txn.statements.avg`` is the average number of bytes
31+
that a single transaction uses for statements (equals
32+
`box.stat.memtx().tx.txn.statements.total`` / number of open transactions).
33+
* ``box.stat.memtx().tx.txn.statements.total`` is the number of bytes that are
34+
currently allocated for statements of all transactions in memtx.
35+
36+
* ``box.stat.memtx().tx.txn.user`` is the memory that a user allocated within
37+
the current transaction using the Tarantool C API function
38+
:ref:`box_txn_alloc() <txn-box_txn_alloc>`.
39+
Tarantool reports the following statistics for this kind of transactions:
40+
* ``box.stat.memtx().tx.txn.user.max`` is the maximal number of bytes
41+
within a transaction allocated using ``box_txn_alloc()``.
42+
* ``box.stat.memtx().tx.txn.user.avg`` is the average number of bytes within
43+
a transaction allocated using ``box_txn_alloc()`` (equals
44+
``box.stat.memtx().tx.txn.user.total`` / number of transaction).
45+
* ``box.stat.memtx().tx.txn.user.total`` is the number of bytes allocated
46+
using ``box_txn_alloc()`` for all transactions in memtx.
47+
48+
* ``box.stat.memtx().tx.txn.system`` is the memory allocated for internal needs
49+
(for example, logs) and savepoints.
50+
Like in the previous sections, Tarantool reports the maximal, average and
51+
total number of allocated bytes.
52+
53+
* ``box.stat.memtx().tx.mvcc`` shows memory allocation related to multiversion
54+
concurrency control (MVCC). MVCC is reposible for isolating transactions.
55+
It reveals conflicts and makes sure that tuples that do not belong to a particular
56+
space but were (or could be) read by some transaction were not deleted.
57+
58+
* ``box.stat.memtx().tx.mvcc.trackers`` is the memory allocated for *trackers*
59+
of transaction reads.
60+
Tarantool reports the following statistics for trackers:
61+
* ``box.stat.memtx().tx.mvcc.trackers.max`` is the maximal number of bytes
62+
allocated for trackers per a single transaction.
63+
* ``box.stat.memtx().tx.mvcc.trackers.avg`` is the average number of bytes
64+
allocated for trackers per a single transaction (equals
65+
``box.stat.memtx().tx.mvcc.trackers.total`` / number of transactions).
66+
* ``box.stat.memtx().tx.mvcc.trackers.total`` is the number of bytes that are
67+
currently allocated for all trackers in memtx.
68+
69+
* ``box.stat.memtx().tx.mvcc.conflicts`` is the memory allocated for *conflicts*
70+
which are entities created when transactional conflicts occur.
71+
Like in the previous sections, Tarantool reports the maximal, average and
72+
total number of allocated bytes.
73+
74+
* ``box.stat.memtx().tx.mvcc.tuples`` is the memory allocated for storing tuples.
75+
With MVCC, tuples are stored using the *stories* mechanism. Nearly every
76+
tuple has its story. Even tuples in an index may have their stories, so
77+
it may be useful to differentiate memory allocated for tuples and memory
78+
allocated for stories.
79+
80+
All stored tuples fall into three categories, with memory statistics
81+
reported for each category:
82+
* ``box.stat.memtx().tx.mvcc.tuples.tracking`` is for tuples that are not used
83+
by any transactions directly, but MVCC uses them for tracking transaction reads.
84+
* ``box.stat.memtx().tx.mvcc.tuples.used`` is for tuples that are used
85+
by active read-write transactions.
86+
* ``box.stat.memtx().tx.mvcc.tuples.read_view`` is for tuples that are not used
87+
by active read-write transactions, but are used by read-only transactions.
88+
89+
For each of the three categories, Tarantool reports two statistical blocks:
90+
* ``stories`` is for stories.
91+
* ``retained`` is for *retained* tuples which do not belong to any index,
92+
but MVCC doesn't allow to delete them yet.
93+
94+
For each block, Tarantool reports the following statistics:
95+
* ``count`` is the number of stories or retained tuples.
96+
* ``total`` is the number of bytes allocated for stories or retained tuples.

0 commit comments

Comments
 (0)