From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A22344765E0 for ; Mon, 28 Dec 2020 06:59:33 +0300 (MSK) Date: Mon, 28 Dec 2020 06:59:27 +0300 From: Igor Munkin Message-ID: <20201228035927.GO5396@tarantool.org> References: <20201228020620.2284-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201228020620.2284-1-skaplun@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH luajit v3 1/2] core: introduce memory profiler List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org 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 . > > 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 > > -- > 2.28.0 > -- Best regards, IM