[Tarantool-patches] [PATCH luajit v2 1/2] memprof: dump traceno if allocate from trace

Sergey Kaplun skaplun at tarantool.org
Sat Aug 14 11:00:51 MSK 2021


Hi!

Thanks for the fixes!

LGTM, except a few nits regarding the commit message and comment in
the code.

On 28.07.21, Mikhail Shishatskiy wrote:
> When LuaJIT executes a trace, the trace number is stored in
> the virtual machine state. So, we can treat this number as
> an allocation event source in memprof and report allocation events
> from traces as well.
> 
> Previously, all the allocations from traces were marked as INTERNAL.
> 
> This patch introduces the functionality described above by adding
> a new allocation source type named ASOURCE_TRACE. If at the moment
> when allocation event occurs VM state indicates that trace executed,
> trace number streamed to a binary file:
> 
> | loc-trace := trace-no
> | trace-no  := <ULEB128>
> 
> Also, the memory profiler parser was adjusted to recognize this

Typo: s/was/is/

> source type by extending <loc> structure: field <traceno>,
> representing trace number, was added.

Typo: s/trace number/a trace number/
Typo: s/was/is/

> 
> Part of tarantool/tarantool#5814
> ---
> 
> Issue: https://github.com/tarantool/tarantool/issues/5814
> Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5814-group-allocations-on-trace-by-trace-number
> CI: https://github.com/tarantool/tarantool/tree/shishqa/gh-5814-group-allocations-on-trace-by-trace-number
> 
>  src/lj_memprof.c        | 14 ++++++++++++--
>  src/lj_memprof.h        | 13 ++++++++-----
>  tools/memprof/parse.lua | 22 ++++++++++++++--------
>  3 files changed, 34 insertions(+), 15 deletions(-)
> 
> diff --git a/src/lj_memprof.c b/src/lj_memprof.c
> index 2c1ef3b8..0c7e9e89 100644
> --- a/src/lj_memprof.c
> +++ b/src/lj_memprof.c

<snipped>

> @@ -168,9 +176,11 @@ static const memprof_writer memprof_writers[] = {
>    ** But since traces must follow the semantics of the original code,
>    ** behaviour of Lua and JITted code must match 1:1 in terms of allocations,
>    ** which makes using memprof with enabled JIT virtually redundant.
> -  ** Hence use the stub below.
> +  ** But if one wants to investigate allocations with JIT enabled,
> +  ** memprof_write_trace() dumps trace number to the binary output. 

Typo: trailing whitespace here ---------------------------------------^

> +  ** It can be useful to compare with with jit.v or jit.dump outputs.
>    */
> -  memprof_write_hvmstate /* LJ_VMST_TRACE */
> +  memprof_write_trace /* LJ_VMST_TRACE */
>  };
>  
>  static void memprof_write_caller(struct memprof *mp, uint8_t aevent)
> diff --git a/src/lj_memprof.h b/src/lj_memprof.h
> index 3417475d..e3f55433 100644
> --- a/src/lj_memprof.h
> +++ b/src/lj_memprof.h

<snipped>

> diff --git a/tools/memprof/parse.lua b/tools/memprof/parse.lua
> index 12e2758f..2d3c71f0 100644
> --- a/tools/memprof/parse.lua
> +++ b/tools/memprof/parse.lua

<snipped>

> -- 
> 2.32.0
> 

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list