-
Notifications
You must be signed in to change notification settings - Fork 43
[5pt] Document LuaJIT getmetrics C and Lua API #1597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@filonenko-mikhail @sharonovd @mtrempoltsev @rosik @orchaton @Mons @msiomkin @vasiliy-t @olegrok @knazarov @Kasen |
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
* add luajit platform metrics After tarantool/tarantool#5187 tarantool could report luajit platform metrics. This patch exports them as default metrics. For detailed description of each metric see tarantool/doc#1597. Closes #127
|
@pgulutzan, thanks for investigation, I've never seen this page. I guess this is a reference to tarantool/metrics, so I still believe we need a separate page for so-called "open source" platform metrics and here are the reasons I see for this:
Considering everything above, I guess the better solution is creating a separate page for LuaJIT platform metrics with the structure similar to LuaJIT memory profiler page and link the new page with the existing one with the comment about the naming with "lj_" prefix. |
@igormunkin: Apparently you are right, the Tarantool manual's "LuaJIT metrics" section |
@pgulutzan, strictly saying, they are not the same. At first, tarantool/metrics module is not provided within Tarantool binary, but the metrics implemented and described by @Buristan are. The items mentioned in "LuaJIT metrics" section are just proxies for the metrics to be added. But you're right, the values obtained via any of the interfaces are exactly the same. |
There is now a pull request issue #2280. Re the earlier discussion (above) about the feature that is so similar |
@pgulutzan, thanks for the changes, they are verbose, clear and just marvelous! The metrics are aboard since 2.6 series, and are not changed except a tiny bug with Re FAQ: you're right, we don't have this section for now, but now we know where to place it. Your and @Buristan examples are fine for the start, so I hope users will start using these platform metrics for troubleshooting, so we can extend the doc with the real world examples later. |
Fixes #1597 Written by Peter Gulutzan, reviewed by Igor Munkin and Sergey Kaplun Translated by ainoneko, translation reviewed by Patience Daur Co-authored-by: Peter Gulutzan <[email protected]> Co-authored-by: Igor Munkin <[email protected]> Co-authored-by: ainoneko <[email protected]> Co-authored-by: Patience Daur <[email protected]>
Root: next to https://www.tarantool.io/en/doc/latest/book/app_server/luajit_memprof/
We finally added C and Lua API for LuaJIT metrics (#5187).
API
The additional header <lmisclib.h> is introduced to extend the existing LuaJIT
C API with new interfaces. The first function provided via this header is the
following:
This function fills the structure pointed to by
metrics
with the correspondingmetrics related to Lua state anchored to the given coroutine
L
.The
struct luam_Metrics
has the following definition:All metrics are collected throughout the platform uptime. These metrics
increase monotonically and can overflow:
strhash_hit
strhash_miss
gc_freed
gc_allocated
gc_steps_pause
gc_steps_propagate
gc_steps_atomic
gc_steps_sweepstring
gc_steps_sweep
gc_steps_finalize
jit_snap_restore
jit_trace_abort
They make sense only with comparing with their value from a previous
luaM_metrics()
call.There is also a complement introduced for Lua space --
misc.getmetrics()
.This function is just a wrapper for
luaM_metrics()
returning a Lua table withthe similar metrics. All returned values are presented as numbers with cast to
double, so there is a corresponding precision loss.
How to use
This section describes small example of metrics usage.
For example amount of
strhash_misses
can be shown for tracking of new stringobjects allocations. For example if we add code like:
increase in slope curve of
strhash_misses
means, that after your changesthere are more new strings allocating at runtime. Of course slope curve of
strhash_misses
should be less than slope curve ofstrhash_hits
.Slope curves of
gc_freed
andgc_allocated
can be used for analysis of GCpressure of your application (less is better).
Also we can check some hacky optimization with these metrics. For example let's
assume that we have this code snippet:
diff
equals to 18879 after running of this chunk.But if we change table initialization to
diff
shows us only 5895.Slope curves of
gc_steps_*
can be used for tracking of GC pressure too. Forlong time observations you will see periodic increment for
gc_steps_*
metrics-- for example longer period of
gc_steps_atomic
increment is better. Alsoadditional amount of
gc_steps_propagate
in one period can be used toindirectly estimate amount of objects. These values also correlate with the
step multiplier of the GC. The amount of incremental steps can grow, but
one step can process a small amount of objects. So these metrics should be
considered together with GC setup.
Amount of
gc_*num
is useful for control of memory leaks -- total amount ofthese objects should not growth nonstop (you can also track
gc_total
forthis). Also
jit_mcode_size
can be used for tracking amount of allocatedmemory for traces machine code.
Slope curves of
jit_trace_abort
shows how many times trace hasn't beencompiled when the attempt was made (less is better).
Amount of
gc_trace_num
is shown how much traces was generated (usuallymore is better).
And the last one --
gc_snap_restores
can be used for estimation when LuaJITis stop trace execution. If slope curves of this metric growth after changing
old code it can mean performance degradation.
Assumes that we have code like this:
diff
equals 3 (1 side exit on loop end, 2 side exits to the interpreterbefore trace gets hot and compiled) after this chunk of code.
And now we decide to change
foo
function like this:diff
equals 6 (1 side exit on loop end, 2 side exits to the interpreterbefore trace gets hot and compiled an 3 side exits from the root trace could
not get compiled) after the same chunk of code.
The text was updated successfully, but these errors were encountered: