Skip to content

Commit 70493eb

Browse files
authored
Add space.stat() and tuple.info() reference (#4373)
Resolves #3841 #3840
1 parent 163b69c commit 70493eb

File tree

5 files changed

+103
-2
lines changed

5 files changed

+103
-2
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 tuple memory usage statistics
15+
listed in the :ref:`box_tuple-info` reference.
16+
17+
.. note::
18+
19+
Memory usage statistics are shown only for the 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: space 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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 wasted due to internal fragmentation in the `slab allocator <https://github.com/tarantool/small>`_.
21+
22+
.. note::
23+
24+
`waste_size` is provided for reference only and can be inaccurate.
25+
Avoid using it for memory usage calculations.
26+
27+
- ``arena`` - type of the arena where the tuple is allocated.
28+
Possible values are: ``memtx``, ``malloc``, ``runtime``.
29+
30+
:return: tuple memory usage statistics
31+
:rtype: table
32+
33+
34+
**Example**
35+
36+
.. code-block:: tarantoolsession
37+
38+
tarantool> box.space.tester:get('222200000'):info()
39+
---
40+
- data_size: 55
41+
waste_size: 95
42+
arena: memtx
43+
field_map_size: 4
44+
header_size: 6
45+
...

doc/release/3.0.0.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ You can see the total memory usage using :ref:`box.slab.info() <box_slab_info>`:
148148
- 75302024
149149
...
150150
151-
A new ``space_object:stat()`` method allows you to determine how the additional 5 Mb of memory is used:
151+
A new `space_object:stat() <box_space-stat>` method allows you to determine how the additional 5 Mb of memory is used:
152152

153153
.. code-block:: console
154154
@@ -173,7 +173,7 @@ The above report gives the following information:
173173
- ``data_size``: the actual size of data, which equals to ``space_object:bsize()``.
174174
- ``waste_size``: the size of memory wasted due to internal fragmentation in the `slab allocator <https://github.com/tarantool/small>`_.
175175

176-
To get such information about a specific tuple, use ``tuple_object:info()``:
176+
To get such information about a specific tuple, use :ref:`tuple_object:info() <box_tuple-info>`:
177177

178178
.. code-block:: console
179179

0 commit comments

Comments
 (0)