diff --git a/doc/reference/reference_lua/box_space.rst b/doc/reference/reference_lua/box_space.rst index 3e1104e07d..cc51bcba00 100644 --- a/doc/reference/reference_lua/box_space.rst +++ b/doc/reference/reference_lua/box_space.rst @@ -88,6 +88,9 @@ Below is a list of all ``box.space`` functions and members. * - :doc:`./box_space/select` - Select one or more tuples + * - :doc:`./box_space/stat` + - Get statistics on memory usage + * - :doc:`./box_space/truncate` - Delete all tuples @@ -202,6 +205,7 @@ To see examples, visit the :ref:`how-to guide on CRUD operations ` + + :return: space memory usage statistics + :rtype: table + + **Possible errors:** ``space_object`` does not exist. + + + **Example:** + + .. code-block:: tarantoolsession + + tarantool> box.space.tester:stat() + --- + - tuple: + memtx: + waste_size: 145 + data_size: 235 + header_size: 36 + field_map_size: 24 + malloc: + waste_size: 0 + data_size: 0 + header_size: 0 + field_map_size: 0 + ... \ No newline at end of file diff --git a/doc/reference/reference_lua/box_tuple.rst b/doc/reference/reference_lua/box_tuple.rst index 619d389e14..eff5175786 100644 --- a/doc/reference/reference_lua/box_tuple.rst +++ b/doc/reference/reference_lua/box_tuple.rst @@ -47,6 +47,9 @@ Below is a list of all ``box.tuple`` functions. * - :doc:`./box_tuple/find` - Get the number of the first field/all fields matching the search value + * - :doc:`./box_tuple/info` + - Get information about the tuple + * - :doc:`./box_tuple/next` - Get the next field value from tuple @@ -82,6 +85,7 @@ Below is a list of all ``box.tuple`` functions. box_tuple/field_name box_tuple/field_path box_tuple/find + box_tuple/info box_tuple/next box_tuple/pairs box_tuple/totable diff --git a/doc/reference/reference_lua/box_tuple/info.rst b/doc/reference/reference_lua/box_tuple/info.rst new file mode 100644 index 0000000000..c9a1cd1f12 --- /dev/null +++ b/doc/reference/reference_lua/box_tuple/info.rst @@ -0,0 +1,45 @@ + +.. _box_tuple-info: + +tuple_object.info() +=================== + +.. class:: tuple_object + + .. method:: info() + + Get information about the tuple memory usage. + + Returns a table with the following fields: + + - ``data_size`` -- size of MessagePack data in the tuple. + This number equals to number returned by :ref:`box_tuple-bsize`. + - ``header_size`` - size of the internal tuple header. + - ``field_map_size`` -- size of the field map. + Field map is used to speed up access to indexed fields of the tuple. + - ``waste_size`` -- amount of excess memory wasted due to internal fragmentation in the `slab allocator `_. + + .. note:: + + `waste_size` is provided for reference only and can be inaccurate. + Avoid using it for memory usage calculations. + + - ``arena`` - type of the arena where the tuple is allocated. + Possible values are: ``memtx``, ``malloc``, ``runtime``. + + :return: tuple memory usage statistics + :rtype: table + + + **Example** + + .. code-block:: tarantoolsession + + tarantool> box.space.tester:get('222200000'):info() + --- + - data_size: 55 + waste_size: 95 + arena: memtx + field_map_size: 4 + header_size: 6 + ... diff --git a/doc/release/3.0.0.rst b/doc/release/3.0.0.rst index 5c2725c672..04b6b4b699 100644 --- a/doc/release/3.0.0.rst +++ b/doc/release/3.0.0.rst @@ -148,7 +148,7 @@ You can see the total memory usage using :ref:`box.slab.info() `: - 75302024 ... -A new ``space_object:stat()`` method allows you to determine how the additional 5 Mb of memory is used: +A new `space_object:stat() ` method allows you to determine how the additional 5 Mb of memory is used: .. code-block:: console @@ -173,7 +173,7 @@ The above report gives the following information: - ``data_size``: the actual size of data, which equals to ``space_object:bsize()``. - ``waste_size``: the size of memory wasted due to internal fragmentation in the `slab allocator `_. -To get such information about a specific tuple, use ``tuple_object:info()``: +To get such information about a specific tuple, use :ref:`tuple_object:info() `: .. code-block:: console