tarantool / tarantool/doc

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

Open
#2,583 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

2.10 feature LuaJIT
Dominant language
CSS
Stars
15
Forks
49
Avg merge
1d 13h
Merged PRs (30d)
3

Description

Product: Tarantool
Since: 2.10
Root document: https://www.tarantool.io/en/doc/latest/book/app_server/luajit_memprof/
Dev issue: https://github.com/tarantool/tarantool/issues/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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the tests.lua chunk and the memprof parser command shown in the issue to reproduce the missing prototype information for lua_global_f() and f(). Trace how allocation events are enriched when new functions are loaded. Done means allocations from those functions are reported with their prototype information rather than only as unresolved CFUNC entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
performance, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.