Skip to content

Commit dea1d68

Browse files
committed
Add space.stat and tuple.info reference
1 parent 24547d9 commit dea1d68

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

doc/reference/reference_lua/box_space.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ Below is a list of all ``box.space`` functions and members.
8888
* - :doc:`./box_space/select`
8989
- Select one or more tuples
9090

91+
* - :doc:`./box_space/stat`
92+
- Get statistics on memory usage
93+
9194
* - :doc:`./box_space/truncate`
9295
- Delete all tuples
9396

@@ -202,6 +205,7 @@ To see examples, visit the :ref:`how-to guide on CRUD operations <box_space_exam
202205
box_space/replace
203206
box_space/run_triggers
204207
box_space/select
208+
box_space/stat
205209
box_space/truncate
206210
box_space/update
207211
box_space/upsert
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. _box_space-stat:
2+
3+
space_object:stat()
4+
===================
5+
6+
.. class:: space_object
7+
8+
.. method:: stat()
9+
10+
Get statistics on memory usage by the space.
11+
12+
Returns a table with the cumulative statistics on the memory usage by tuples in the space.
13+
Statistics are grouped by arena types: ``memtx`` or ``malloc``.
14+
For each arena type, the return table includes the sum of memory usage statitics
15+
of tuples stored in this arena. See :ref:`box_tuple-info` for details.
16+
17+
.. note::
18+
19+
The statistics is collected only for memtx storage engine.
20+
For other types of spaces, an empty table is returned.
21+
22+
:param space_object space_object: an :ref:`object reference
23+
<app_server-object_reference>`
24+
25+
:return: memory usage statistics
26+
:rtype: table
27+
28+
**Possible errors:** ``space_object`` does not exist.
29+
30+
31+
**Example:**
32+
33+
.. code-block:: tarantoolsession
34+
35+
tarantool> box.space.tester:stat()
36+
---
37+
- tuple:
38+
memtx:
39+
waste_size: 145
40+
data_size: 235
41+
header_size: 36
42+
field_map_size: 24
43+
malloc:
44+
waste_size: 0
45+
data_size: 0
46+
header_size: 0
47+
field_map_size: 0
48+
...

doc/reference/reference_lua/box_tuple.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Below is a list of all ``box.tuple`` functions.
4747
* - :doc:`./box_tuple/find`
4848
- Get the number of the first field/all fields matching the search value
4949

50+
* - :doc:`./box_tuple/info`
51+
- Get information about the tuple
52+
5053
* - :doc:`./box_tuple/next`
5154
- Get the next field value from tuple
5255

@@ -82,6 +85,7 @@ Below is a list of all ``box.tuple`` functions.
8285
box_tuple/field_name
8386
box_tuple/field_path
8487
box_tuple/find
88+
box_tuple/info
8589
box_tuple/next
8690
box_tuple/pairs
8791
box_tuple/totable
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
.. _box_tuple-info:
3+
4+
tuple_object.info()
5+
===================
6+
7+
.. class:: tuple_object
8+
9+
.. method:: info()
10+
11+
Get information about the tuple memory usage.
12+
13+
Returns a table with the following fields:
14+
15+
- ``data_size`` -- size of MessagePack data in the tuple.
16+
This number equals to number returned by :ref:`box_tuple-bsize`.
17+
- ``header_size`` - size of the internal tuple header.
18+
- ``field_map_size`` -- size of the field map.
19+
Field map is used to speed up access to indexed fields of the tuple.
20+
- ``waste_size`` -- amount of excess memory used to store the tuple
21+
in mempool.
22+
- ``arena`` - type of the arena where the tuple is allocated.
23+
Possible values are: ``memtx``, ``malloc``, ``runtime``.
24+
25+
:return: table
26+
27+
**Example**
28+
29+
.. code-block:: tarantoolsession
30+
31+
tarantool> box.space.tester:get('222200000'):info()
32+
---
33+
- data_size: 55
34+
waste_size: 95
35+
arena: memtx
36+
field_map_size: 4
37+
header_size: 6
38+
...

0 commit comments

Comments
 (0)