Skip to content

Commit 0e623f2

Browse files
committed
Review by doc team: some more text brushup
1 parent 0173bef commit 0e623f2

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

doc/tooling/luajit_memprof.rst

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
LuaJIT memory profiler
44
======================
55

6-
Starting from version :doc:`2.7.1 </release/2.7.1>`, Tarantool
6+
Since version :doc:`2.7.1 </release/2.7.1>`, Tarantool
77
has a built‑in module called ``misc.memprof`` that implements a LuaJIT memory
8-
profiler (which we will just call *the profiler* in this section). The profiler provides
9-
a memory allocation report that helps analyze Lua code and find the places
10-
that put the most pressure on the Lua garbage collector (GC).
8+
profiler (further in this section we call it *the profiler* for short).
9+
The profiler provides a memory allocation report that helps analyze Lua code
10+
and find the places that put the most pressure on the Lua garbage collector (GC).
11+
12+
Inside this section:
1113

1214
.. contents::
1315
:local:
@@ -18,7 +20,7 @@ that put the most pressure on the Lua garbage collector (GC).
1820
Working with the profiler
1921
-------------------------
2022

21-
Usage of the profiler involves two steps:
23+
The profiler usage involves two steps:
2224

2325
1. :ref:`Collecting <profiler_usage_get>` a binary profile of allocations,
2426
reallocations, and deallocations in memory related to Lua
@@ -28,13 +30,13 @@ Usage of the profiler involves two steps:
2830

2931
.. _profiler_usage_get:
3032

31-
Collecting binary profile
32-
~~~~~~~~~~~~~~~~~~~~~~~~~
33+
Collecting a binary profile
34+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3335

3436
To collect a binary profile for a particular part of the Lua code,
3537
you need to place this part between two ``misc.memprof`` functions,
3638
namely, ``misc.memprof.start()`` and ``misc.memprof.stop()``, and then execute
37-
the code under Tarantool.
39+
the code in Tarantool.
3840

3941
Below is a chunk of Lua code named ``test.lua`` to illustrate this.
4042

@@ -75,6 +77,7 @@ for example if it is not possible to open a file for writing or if the profiler
7577
``misc.memprof.start()`` returns ``nil`` as the first result,
7678
an error-message string as the second result,
7779
and a system-dependent error code number as the third result.
80+
7881
If the operation succeeds, ``misc.memprof.start()`` returns ``true``.
7982

8083
The Lua code for stopping the profiler -- as in line 18 in the ``test.lua`` example above -- is:
@@ -89,13 +92,14 @@ or if there is a failure during reporting,
8992
``misc.memprof.stop()`` returns ``nil`` as the first result,
9093
an error-message string as the second result,
9194
and a system-dependent error code number as the third result.
95+
9296
If the operation succeeds, ``misc.memprof.stop()`` returns ``true``.
9397

9498
.. _profiler_usage_generate:
9599

96100
To generate the file with memory profile in binary format
97101
(in the :ref:`test.lua code example above <profiler_usage_example01>`
98-
the file name is ``memprof_new.bin``), execute the code under Tarantool:
102+
the file name is ``memprof_new.bin``), execute the code in Tarantool:
99103

100104
.. code-block:: console
101105
@@ -127,8 +131,8 @@ a profiling report:
127131

128132
.. _profiler_usage_parse:
129133

130-
Parsing binary profile and generating profiling report
131-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134+
Parsing a binary profile and generating a profiling report
135+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132136

133137
.. _profiler_usage_parse_command:
134138

@@ -143,8 +147,11 @@ via Tarantool by using the following command
143147
144148
where ``memprof_new.bin`` is the binary profile
145149
:ref:`generated earlier <profiler_usage_generate>` by ``tarantool test.lua``.
146-
(Warning: there is a slight behavior change here, the ``tarantool -e ...``
147-
command was slightly different in Tarantool versions prior to Tarantool 2.8.1.)
150+
151+
.. note::
152+
153+
There is a slight behavior change here: the ``tarantool -e ...`` command
154+
was slightly different in Tarantool versions prior to Tarantool 2.8.1.
148155

149156
Tarantool generates a profiling report and displays it on the console before closing
150157
the session:
@@ -187,7 +194,6 @@ the session:
187194
On macOS, a report will be different for the same chunk of code because
188195
Tarantool and LuaJIT are built with the GC64 mode enabled for macOS.
189196

190-
191197
Let's examine the report structure. A report has four sections:
192198

193199
* ALLOCATIONS
@@ -255,10 +261,10 @@ structures.
255261
As for investigating the Lua code with the help of profiling reports,
256262
it is always code-dependent and there can't be hundred per cent definite
257263
recommendations in this regard. Nevertheless, you can see some of the things
258-
in the :ref:`Profiling report analysis example <profiler_analysis>` later.
264+
in the :ref:`Profiling a report analysis example <profiler_analysis>` later.
259265

260266
Also, below is the :ref:`FAQ <profiler_faq>` section with the questions that
261-
most probably can arise while using profiler.
267+
most probably can arise while using the profiler.
262268

263269
.. _profiler_faq:
264270

@@ -342,18 +348,18 @@ console for a running instance.
342348
log.warn("end of profile")
343349
end)
344350
345-
where
351+
where:
346352

347-
* ``FILENAME``—the name of the binary file where profiling events are written
348-
* ``TIME``—duration of profiling, in seconds.
353+
* ``FILENAME``—the name of the binary file where profiling events are written
354+
* ``TIME``—duration of profiling, in seconds.
349355

350356
Also, you can directly call ``misc.memprof.start()`` and ``misc.memprof.stop()``
351357
from a console.
352358

353359
.. _profiler_analysis:
354360

355-
Profiling report analysis example
356-
---------------------------------
361+
Profiling a report analysis example
362+
-----------------------------------
357363

358364
In the example below, the following Lua code named ``format_concat.lua`` is
359365
investigated with the help of the memory profiler reports.
@@ -395,7 +401,7 @@ investigated with the help of the memory profiler reports.
395401
396402
os.exit()
397403
398-
When you run this code :ref:`under Tarantool <profiler_usage_generate>` and
404+
When you run this code :ref:`in Tarantool <profiler_usage_generate>` and
399405
then :ref:`parse <profiler_usage_parse_command>` the binary memory profile
400406
in /tmp/memprof_format_concat.bin,
401407
you will get the following profiling report:
@@ -468,8 +474,8 @@ To profile only the ``concat()`` function, comment out line 23 (which is
468474
**Q**: But what will change if JIT compilation is enabled?
469475

470476
**A**: In the :ref:`code <profiler_usage_example03>`, comment out line 2 (which is
471-
``jit.off()``) and run
472-
the profiler . Now there are only 56 allocations in the report, and all other
477+
``jit.off()``) and run the profiler.
478+
Now there are only 56 allocations in the report, and all the other
473479
allocations are JIT-related (see also the related
474480
`dev issue <https://github.com/tarantool/tarantool/issues/5679>`_):
475481

@@ -535,7 +541,7 @@ identifier is not yet compiled via LuaJIT. So, a trace can't be recorded and
535541
the compiler doesn't perform the corresponding optimizations.
536542

537543
If we change the ``format()`` function in lines 9-12 of the
538-
:ref:`Profiling report analysis example <profiler_usage_example03>`
544+
:ref:`Profiling a report analysis example <profiler_usage_example03>`
539545
in the following way
540546

541547
.. code-block:: lua
@@ -591,4 +597,4 @@ for example
591597
592598
$ tarantool -e 'require("memprof")(arg)' - --leak-only memprof_new.bin
593599
594-
When `--leak-only`` is used, only the HEAP SUMMARY section is displayed.
600+
When ``--leak-only`` is used, only the HEAP SUMMARY section is displayed.

doc/tooling/luajit_sysprof.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ able to show the host stack, so all the Lua calls are displayed as a single
99
``pcall()``. Oppositely, the ``jit.p`` module provided with LuaJIT
1010
is not able to give any information about the host stack.
1111

12-
Starting from version :doc:`2.10.0 </release/2.10.0>`, Tarantool
12+
Since version :doc:`2.10.0 </release/2.10.0>`, Tarantool
1313
has a built‑in module called ``misc.sysprof`` that implements a
14-
LuaJIT sampling profiler (which we will just call *the profiler*
15-
in this section). The profiler is able to capture both guest and
14+
LuaJIT sampling profiler (further in this section we call it *the profiler*
15+
for short). The profiler can capture both guest and
1616
host stacks simultaneously, along with virtual machine states, so
1717
it can show the whole picture.
1818

@@ -25,6 +25,8 @@ Three profiling modes are available:
2525
The profiler comes with a default parser, which produces output in
2626
a ``flamegraph.pl``-suitable format.
2727

28+
Inside this section:
29+
2830
.. contents::
2931
:local:
3032
:depth: 2
@@ -87,8 +89,9 @@ The Lua code for starting the profiler -- as in line 1 in the
8789
local str, err = misc.sysprof.start({mode = 'C', interval = 1, path = 'sysprof.bin'})
8890
8991
where:
90-
* ``mode`` is a profiling mode,
91-
* ``interval`` is a sampling interval,
92+
93+
* ``mode`` is a profiling mode;
94+
* ``interval`` is a sampling interval;
9295
* ``sysprof.bin`` is the name of the binary file where profiling events are written.
9396

9497
If the operation fails, for example if it is not possible to open

0 commit comments

Comments
 (0)