[Tarantool-patches] [PATCH luajit v3 1/2] core: introduce memory profiler

Igor Munkin imun at tarantool.org
Mon Dec 28 06:59:27 MSK 2020


Sergey,

Thanks for the fixes! LGTM.

On 28.12.20, Sergey Kaplun wrote:
> This patch introduces memory profiler for Lua machine.
> 
> To determine currently allocating coroutine (that may not be equal to
> currently executed one) a new field mem_L is added to the
> global_State structure. This field is set on each allocation event and
> stores the coroutine address that is used for allocation.
> 
> First of all profiler dumps the definitions of all loaded Lua functions
> (symtab) via the write buffer introduced in one of the previous patches.
> 
> Profiler replaces the old allocation function with the instrumented one
> after symtab is dumped. This new function reports all allocations,
> reallocations or deallocations events via the write buffer during
> profiling. Subsequent content depends on the function's type (LFUNC,
> FFUNC or CFUNC).
> 
> When profiling is over, a special epilogue event header is written and
> the old allocation function is restored back.
> 
> This change also makes debug_frameline function LuaJIT-wide visible to
> be used in the memory profiler.
> 
> For more information, see <lj_memprof.h>.
> 
> Part of tarantool/tarantool#5442
> ---
> 
> Changes in v3:
>   * Fixed invalid pointer usage at on_stop cb.
>   * Dropped thread safe logic.
>   * Dropped unused functions.
>   * Added assertion to memprof_write_lfunc.
>   * Codestyle fixes.
> 
>  src/Makefile     |   5 +-
>  src/Makefile.dep |  30 +++--
>  src/lj_arch.h    |  15 +++
>  src/lj_debug.c   |   8 +-
>  src/lj_debug.h   |   3 +
>  src/lj_gc.c      |   7 +-
>  src/lj_gc.h      |   1 +
>  src/lj_memprof.c | 344 +++++++++++++++++++++++++++++++++++++++++++++++
>  src/lj_memprof.h | 159 ++++++++++++++++++++++
>  src/lj_obj.h     |   1 +
>  src/lj_state.c   |   7 +
>  src/ljamalg.c    |   1 +
>  12 files changed, 561 insertions(+), 20 deletions(-)
>  create mode 100644 src/lj_memprof.c
>  create mode 100644 src/lj_memprof.h
> 

<snipped>

> -- 
> 2.28.0
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list