Skip to content

Commit 59e0eec

Browse files
authored
doc: write overview on slab tab in tcm ui (#5369)
* doc: write overview on slab tab in tcm ui
1 parent 6e1f1c4 commit 59e0eec

File tree

2 files changed

+132
-7
lines changed

2 files changed

+132
-7
lines changed
83.3 KB
Loading

doc/tooling/tcm/tcm_ui_overview.rst

Lines changed: 132 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To log into |tcm| after bootstrap, use the following credentials:
3636
After logging in with the default password:
3737

3838
#. Adjust the :ref:`password policy <tcm_access_control_password_policy>`
39-
in accordance to the security requirements that apply in your organization.
39+
in accordance with the security requirements that apply in your organization.
4040
#. Change the ``admin`` user's password on the :ref:`User settings <tcm_ui_user_settings>` page.
4141

4242
To log out of |tcm|, click the user's name in the header and click **Log out**.
@@ -64,7 +64,7 @@ Onboarding
6464
----------
6565

6666
The **Onboarding** item of the navigation pane starts the interactive onboarding
67-
tutorial. Use it to get familiar with main |tcm| features directly in the web interface.
67+
tutorial. Use it to get familiar with the main |tcm| features directly in the web interface.
6868

6969
.. _tcm_ui_visibility:
7070

@@ -92,7 +92,7 @@ There are the following page groups:
9292
- **Tools**: |tcm| administration.
9393
- **Settings**: runtime management of |tcm| settings.
9494

95-
Read on to learn what you can do on pages of these groups.
95+
Read on to learn what you can do on the pages of these groups.
9696

9797
.. _tcm_ui_cluster:
9898

@@ -156,14 +156,139 @@ The instance page has an **Actions** menu at the top that allows you to:
156156
- edit the instance configuration
157157
- remove the instance
158158

159+
Slabs tab overview
160+
~~~~~~~~~~~~~~~~~~
161+
162+
The **Slabs** tab in the TCM Web UI visualizes memory allocation within each Tarantool instance using the slab allocator.
163+
164+
This tab is useful for:
165+
166+
- identifying memory fragmentation
167+
- analyzing slab saturation by object size
168+
- debugging excessive memory use in real time
169+
170+
Data source
171+
^^^^^^^^^^^
172+
173+
This visualization is based on the output of:
174+
175+
.. code-block:: lua
176+
177+
box.slab.stats()
178+
179+
This function returns a Lua table with per-class (per object size) memory allocation statistics from the slab allocator.
180+
More about :ref:`box.slab.stats() <box_slab_stats>`.
181+
182+
Each entry in the output contains:
183+
184+
- ``item_size``: object size class
185+
- ``slab_count``: number of slab blocks
186+
- ``slab_size``: memory size of each slab
187+
- ``item_count``: number of allocated objects
188+
- ``mem_used``: bytes used
189+
- ``mem_free``: bytes free
190+
191+
These values are parsed and rendered as visual elements in the UI.
192+
193+
Slab visualization
194+
^^^^^^^^^^^^^^^^^^
195+
196+
Each block represents a single slab (a fixed-size memory region). The color indicates how full the slab is:
197+
198+
- **Green** — the slab is less than 30% full
199+
- **Red** — slab is full (100% usage)
200+
- **Gradient colors between green and red** — indicate intermediate fill levels (e.g., 30%, 50%, 75%)
201+
202+
The color transitions smoothly, providing a quick visual way to understand which slabs are:
203+
204+
- actively used
205+
- partially utilized
206+
- potentially underused or contributing to memory fragmentation
207+
208+
In the example screenshot:
209+
210+
- Slab #17 (168 KB) — 75% full (dark red)
211+
- Slab #18 (320 KB) — 53% full (brownish-red)
212+
- Slab #16 (40 KB) — only 1% used (bright green)
213+
- Slab #2 (56 B) — 60% used (intermediate gradient)
214+
215+
Each slab block’s size in the visualization reflects the total memory allocated for its ``item_size`` class --
216+
the more memory allocated, the larger the visual representation.
217+
218+
.. image:: _images/tcm_ui_slabs.png
219+
:width: 1100px
220+
221+
Calculating fill percentage
222+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
223+
224+
The overall fill percentage for a slab is calculated using:
225+
226+
.. code-block:: text
227+
228+
fill % = (item_count * item_size) / (slab_count * slab_size)
229+
230+
However, each slab is visualized individually, so different fill levels across slabs will result in various colors within the same row.
231+
232+
Behavior across Tarantool instances
233+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
234+
235+
Slab allocation may vary between instances in the same replicaset due to differences in configuration, data loading order, and use of local memory.
236+
The reasons are:
237+
238+
1. Slab allocation may differ because each instance can use its own values for ``slab_alloc_factor`` and ``slab_alloc_granularity``. These parameters control how memory is divided into size classes and slabs, affecting memory layout and potential fragmentation.
239+
2. Differences also appear during replica join or restart. A replica allocates memory for tuples in primary index order, while on the master, allocation follows the order of incoming requests. This results in different slab structures and usually lower fragmentation on replicas after a restart.
240+
3. Local and temporary spaces exist only on specific instances and are not replicated. They consume memory independently and contribute to differences in slab allocation across nodes.
241+
242+
Slab allocator tuning
243+
^^^^^^^^^^^^^^^^^^^^^
244+
245+
You can fine-tune the allocator behavior with two configuration options:
246+
247+
- :ref:`slab_alloc_factor <configuration_reference_memtx_slab_alloc_factor>` – multiplier for calculating object size classes. Default value: ``1.05``
248+
- :ref:`slab_alloc_granularity <configuration_reference_memtx_slab_alloc_granularity>` – minimum allocation step (in bytes) for the small allocator. Default value: ``8``
249+
250+
These parameters affect how memory is allocated per object size class and can help:
251+
252+
- reduce internal fragmentation
253+
- optimize memory usage
254+
- improve slab locality and performance
255+
- better understand memory consumption via the **Slabs** tab
256+
257+
Use cases and recommendations table:
258+
259+
.. list-table::
260+
:header-rows: 1
261+
:widths: 20 20 20 20 20
262+
263+
* - Scenario / Goal
264+
- Parameters (`slab_alloc_factor` / `slab_alloc_granularity`)
265+
- Effect on memory
266+
- Effect on performance
267+
- Visualization in **Slabs** tab
268+
* - Reduce memory waste (small, uniform tuples)
269+
- ``1.05`` / ``4``
270+
- Many size classes – minimal internal memory waste
271+
- Higher overhead for managing slab pools
272+
- Many rows, partially filled blocks, gradient from green to red
273+
* - Optimize performance (mixed-size tuples)
274+
- ``1.3`` / ``16``
275+
- Fewer size classes – slightly more memory waste
276+
- Lower overhead – faster memory allocation
277+
- Fewer rows, larger blocks, color contrast: partially or filled
278+
* - Control fragmentation and slab count
279+
- Task-dependent: lower values – more classes; higher values – fewer classes
280+
- Balance between internal memory waste and the number of blocks
281+
- Balance between overhead and allocator speed
282+
- Balance between number of rows and block sizes; colors indicate fill level
283+
159284
.. _tcm_ui_cluster_config:
160285

161286
Configuration
162287
~~~~~~~~~~~~~
163288

164289
The cluster **Configuration** page provides an interactive editor for the cluster
165290
:ref:`configuration <configuration>`. It is connected to the centralized configuration
166-
storage that the cluster uses. All changes you make and apply on this page are
291+
storage that the cluster uses. All changes you make and apply to this page are
167292
sent to this centralized storage.
168293

169294
.. image:: _images/tcm_ui_config.png
@@ -211,7 +336,7 @@ Tuples
211336
The cluster-wide access to stored data on the **Tuples** page is supported only
212337
for sharded clusters that use the `CRUD <https://github.com/tarantool/crud>`__ module.
213338

214-
The **Tuples** page provides access to data stored in user spaces of the selected
339+
The **Tuples** page provides access to data stored in the user spaces of the selected
215340
cluster.
216341

217342
.. image:: _images/tcm_ui_tuples.png
@@ -221,7 +346,7 @@ cluster.
221346

222347
On this page, you can:
223348

224-
- view the list of user spaces, their size and engines
349+
- view the list of user spaces, their size, and engines
225350
- view and edit tuples stored in user spaces
226351

227352
.. _tcm_ui_cluster_tcf:
@@ -273,7 +398,7 @@ including system spaces.
273398

274399
On this page, you can:
275400

276-
- view and edit instance spaces, their size and engines
401+
- view and edit instance spaces, their size, and engines
277402
- view and edit tuples stored in all spaces of the instance
278403

279404
.. _tcm_ui_clusters:

0 commit comments

Comments
 (0)