Skip to content

[2pt] Enrich symtab when the new function's prototype is allocated #2583

Open
@veod32

Description

@veod32

Product: Tarantool
Since: 2.10
Root document: https://www.tarantool.io/en/doc/latest/book/app_server/luajit_memprof/
Dev issue: tarantool/tarantool#5815
SME: @ igormunkin , @ Buristan

Details

If one runs this test chunk named <tests.lua>:

1  jit.off()
2
3  local ffi = require 'ffi'
4
5  local binfile = "/tmp/memprof_"..(arg[0]):match("([^/]*).lua")..".bin"
6
7  local st, err = misc.memprof.start(binfile)
8  assert(st, err)
9
10 local chunk = [[
11 local t = {
12   string.rep("x", 11111), 42, nil
13 }
14
15 function lua_global_f()
16   local str = string.rep("1", 1024 * 1024)
17 end
18 ]]
19
20 local f, err = loadstring(chunk)
21 assert(f, err)
22 f()
23 lua_global_f()
24
25 collectgarbage()
26
27 local st, err = misc.memprof.stop()
28 assert(st, err)

by Tarantool:

$ tarantool tests.lua

and runs the profiler parser, the output is the following:

$ tarantool -e 'require("memprof")(arg[1])' - /tmp/memprof_tests.bin
ALLOCATIONS
@tests.lua:0, line 20: 17	1736	0
@builtin/strict.lua:14, line 15: 3	458	0
CFUNC 0x401747a0: 1	1048593	0  --<-- lua_global_f()
CFUNC 0x41ea1e18: 1	11128	0  --<-- f()
CFUNC 0x41ea1e18: 1	20	0
CFUNC 0x41ea1e18: 1	72	0
...

This happens because the prototype of the lua_global_f() and f() functions does not exist when the profiler starts.
To report allocations from the new functions, the allocation events should be enriched with the info about new prototypes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.10LuaJIT[area] Related to the LuaJIT compilerfeatureA new functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions