Skip to content

Commit 6021bcc

Browse files
committed
memtx: apply review suggestions (part 1)
Apply review suggestions
1 parent aabfa4a commit 6021bcc

File tree

4 files changed

+145
-232
lines changed

4 files changed

+145
-232
lines changed

doc/code_snippets/snippets/config/instances.enabled/memtx/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
memtx:
2-
memory: 100000000
2+
memory: 1073741824
33
allocator: 'small'
44
min_tuple_size: 8
5-
max_tuple_size: 1048576
5+
max_tuple_size: 5242880
66
slab_alloc_factor: 1.05
77
slab_alloc_granularity: 8
88
sort_threads: 256

doc/concepts/configuration/configuration_memtx.rst

Lines changed: 27 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,42 @@ In Tarantool, all data is stored in random-access memory (RAM) by default.
99
For this purpose, the :ref:`memtx <engines-memtx>` storage engine is used.
1010

1111
This topic describes how to define settings related to in-memory storage in the
12-
:ref:`memtx <configuration_reference_memtx>` section of a :ref:`YAML configuration <configuration>`.
12+
:ref:`memtx <configuration_reference_memtx>` section of a :ref:`YAML configuration <configuration>`
13+
-- for example, :ref:`memory size <configuration_reference_memtx_memory>` and :ref:`maximum tuple size <>configuration_reference_memtx_max_size`.
1314

1415
.. NOTE::
1516

16-
To calculate the required amount of memory, you can use the
17+
To estimate the required amount of memory, you can use the
1718
`sizing calculator <https://www.tarantool.io/en/sizing_calculator/>`_.
1819

1920
.. _configuration_memtx-memory:
2021

21-
Configure the memory size
22-
-------------------------
22+
Memory size
23+
-----------
2324

2425
In Tarantool, data is stored in spaces.
2526
Each space consists of tuples -- the database records.
26-
To specify the amount of memory that Tarantool allocates to actually store tuples, use the
27-
:ref:`memtx.memory <configuration_reference_snapshot_dir>` configuration option.
27+
To specify the amount of memory that Tarantool allocates to store tuples, use the
28+
:ref:`memtx.memory <configuration_reference_memtx_memory>` configuration option.
2829

29-
In the example below, the memory size is 100000000 bytes, which is about 95 MB.
30-
The server does not exceeds this limit to allocate tuples.
31-
For indexes and connection information, the additional memory is used.
32-
33-
When the ``memtx.memory`` limit is reached, ``INSERT`` or ``UPDATE`` requests fail with
34-
:ref:`ER_MEMORY_ISSUE <admin-troubleshoot-memory-issues>`.
30+
In the example below, the memory size is set to 1 GB (1073741824 bytes).
3531

3632
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/memtx/config.yaml
3733
:language: yaml
3834
:start-at: memtx:
39-
:end-at: 100000000
35+
:end-at: 1073741824
4036
:dedent:
4137

38+
The server does not exceed this limit to allocate tuples.
39+
For indexes and connection information, additional memory is used.
40+
41+
When the ``memtx.memory`` limit is reached, ``INSERT`` or ``UPDATE`` requests fail with
42+
:ref:`ER_MEMORY_ISSUE <admin-troubleshoot-memory-issues>`.
43+
4244
.. _configuration_memtx-allocator:
4345

44-
Specify the allocator type
45-
--------------------------
46+
Allocator type
47+
--------------
4648

4749
The allocators are the memory managers used for different purposes.
4850
To set the allocator type that manages memory for ``memtx`` tuples, use the :ref:`memtx.allocator <configuration_reference_memtx_allocator>`
@@ -64,14 +66,12 @@ The example below shows how to specify the ``small`` allocator type:
6466

6567
.. _configuration_memtx-min-max:
6668

67-
Specify the size limitations of the allocation unit
68-
---------------------------------------------------
69+
Tuple size
70+
----------
6971

7072
You can configure the sizes of the smallest and the largest units to allocate.
7173

72-
To set the minimum size in bytes, use the :ref:`memtx.min_tuple_size <configuration_reference_memtx_min_size>` configuration option.
73-
The setting can be useful if the tuples that you store are small.
74-
The minimum size is a value between 8 and 1048280 inclusive.
74+
To set the minimum size in bytes, use the :ref:`memtx.min_tuple_size <configuration_reference_memtx_min_size>` configuration option:
7575

7676
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/memtx/config.yaml
7777
:language: yaml
@@ -80,19 +80,19 @@ The minimum size is a value between 8 and 1048280 inclusive.
8080
:dedent:
8181

8282
To set the maximum size in bytes, use the :ref:`memtx.max_tuple_size <configuration_reference_memtx_max_size>` configuration option.
83-
The setting can be useful if the tuples that you store are large.
83+
In the example, the maximum size is set to 5 MB:
8484

8585
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/memtx/config.yaml
8686
:language: yaml
8787
:start-at: max_tuple_size:
88-
:end-at: 1048576
88+
:end-at: 5242880
8989
:dedent:
9090

9191

9292
.. _configuration_memtx-slab-alloc-granularity:
9393

94-
Specify the granularity for slab allocation
95-
-------------------------------------------
94+
Granularity for slab allocation
95+
-------------------------------
9696

9797
If you use the :ref:`small <configuration_reference_memtx_allocator>` type of allocator, you can set the granularity of
9898
memory allocation in it.
@@ -115,10 +115,10 @@ In the example below, the value is increased to store different-sized tuples:
115115

116116
.. _configuration_memtx-slab-alloc-factor:
117117

118-
Specify the slab allocation factor
119-
----------------------------------
118+
Slab allocation factor
119+
----------------------
120120

121-
The size and number of memory pools depends on allocation factor and granularity.
121+
The size and number of memory pools depend on the allocation factor and granularity.
122122
The allocation factor is a multiplier used to calculate the sizes of memory chunks that tuples are stored in.
123123
To configure the allocation factor, use the :ref:`memtx.slab_alloc_factor <configuration_reference_memtx_slab_alloc_factor>`
124124
configuration option.
@@ -148,86 +148,3 @@ In the example, the maximum number of threads is used (256):
148148
:start-at: sort_threads:
149149
:end-at: 256
150150
:dedent:
151-
152-
.. _configuration_memtx-statistics:
153-
154-
Check the database statistics
155-
-----------------------------
156-
157-
Tarantool provides the statistics about memory consumption for the given space or specific tuples.
158-
Available statistics:
159-
160-
* The amount of memory used for the :ref:`data of the specified space <configuration_memtx-statistics-space>`.
161-
* The amount of :ref:`additional memory <configuration_memtx-statistics-additional>` used for the supplementary information.
162-
* The :ref:`total memory usage <configuration_memtx-statistics-total>`.
163-
164-
.. _configuration_memtx-statistics-space:
165-
166-
Space
167-
~~~~~
168-
169-
To get the get the amount of memory in bytes occupied by the specified space, use the :ref:`space_object:bsize() <box_space-bsize>` method.
170-
The function returns the total number of bytes in all tuples.
171-
172-
.. code-block:: console
173-
174-
memtx:instance001> box.space.books:bsize()
175-
---
176-
- 70348673
177-
...
178-
179-
.. _configuration_memtx-statistics-additional:
180-
181-
Additional memory
182-
~~~~~~~~~~~~~~~~~
183-
184-
To check the usage of the additional memory, use the ``space_object:stat()`` method.
185-
The following information is provided:
186-
187-
- ``header_size`` and ``field_map_size``: the size of service information.
188-
- ``data_size``: the actual size of data, which equals to ``space_object:bsize()``.
189-
- ``waste_size``: the size of memory wasted due to internal fragmentation in the `slab allocator <https://github.com/tarantool/small>`_.
190-
191-
.. code-block:: console
192-
193-
memtx:instance001> box.space.books:stat()
194-
---
195-
- tuple:
196-
memtx:
197-
waste_size: 1744011
198-
data_size: 70348673
199-
header_size: 2154132
200-
field_map_size: 0
201-
malloc:
202-
waste_size: 0
203-
data_size: 0
204-
header_size: 0
205-
field_map_size: 0
206-
...
207-
208-
To get the usage of the additional memory (5 Mb) for the specified tuple, use ``tuple_object:info()``:
209-
210-
.. code-block:: console
211-
212-
memtx:instance001> box.space.books:get('1853260622'):info()
213-
---
214-
- data_size: 277
215-
waste_size: 9
216-
arena: memtx
217-
field_map_size: 0
218-
header_size: 10
219-
...
220-
221-
.. _configuration_memtx-statistics-total:
222-
223-
Total memory usage
224-
~~~~~~~~~~~~~~~~~~
225-
226-
To get the total memory usage in bytes for the slab allocator, use the :ref:`box.slab.info() <box_slab_info>` function:
227-
228-
.. code-block:: console
229-
230-
memtx:instance001> box.slab.info().items_used
231-
---
232-
- 75302024
233-
...

doc/reference/configuration/cfg_storage.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
Since version 1.7.4.
2424

25-
How much memory Tarantool allocates to actually store tuples.
25+
How much memory Tarantool allocates to store tuples.
2626
When the limit is reached, :ref:`INSERT <box_space-insert>` or
2727
:ref:`UPDATE <box_space-insert>` requests begin failing with
2828
error :errcode:`ER_MEMORY_ISSUE`. The server does not go beyond the
@@ -43,7 +43,6 @@
4343

4444
Size of the largest allocation unit, for the memtx storage engine. It can be
4545
increased if it is necessary to store large tuples.
46-
See also: :ref:`vinyl_max_tuple_size <cfg_storage-vinyl_max_tuple_size>`.
4746

4847
| Type: integer
4948
| Default: 1024 * 1024 = 1048576 bytes
@@ -57,11 +56,11 @@
5756
Since version 1.7.4.
5857

5958
Size of the smallest allocation unit. It can be decreased if most
60-
of the tuples are very small. The value must be between 8 and 1048280
61-
inclusive.
59+
of the tuples are very small.
6260

6361
| Type: integer
6462
| Default: 16 bytes
63+
| Possible values: between 8 and 1048280 inclusive
6564
| Environment variable: TT_MEMTX_MIN_TUPLE_SIZE
6665
| Dynamic: no
6766

0 commit comments

Comments
 (0)