tarantool / doc

Tarantool documentation
https://www.tarantool.io/en/doc/
Other
15 stars 43 forks source link

memprof: group allocations on traces by trace number #2585

Open veod32 opened 2 years ago

veod32 commented 2 years ago

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/5814 SME: @ igormunkin , @ Buristan

Details

We already know the number of a trace being executed where an allocation event happens. So we can simplify debugging by reporting not INTERNAL: but TRACE [n]: with the allocation event. It enables users to compare this output with jit.dump() and so on.

mkokryashkin commented 2 years ago

Consider the following chunk of code:

local function allocate()
  a = {}
  for i=1,1e6 do table.insert(a, "Hello, world!") end
  return a
end

jit.on()
allocate()
misc.memprof.start('memprof.bin')
allocate()
misc.memprof.stop()

Report before the patchset:

ALLOCATIONS
@test.lua:3: 1 events   +32 bytes       -0 bytes
@test.lua:4: 1 events   +24 bytes       -0 bytes

REALLOCATIONS
INTERNAL: 19 events     +16777336 bytes -8388744 bytes
        Overrides:
                @test.lua:4
                INTERNAL

DEALLOCATIONS

HEAP SUMMARY:
INTERNAL holds 8388576 bytes: 18 allocs, 18 frees
@test.lua:4 holds 40 bytes: 2 allocs, 1 frees
@test.lua:3 holds 32 bytes: 1 allocs, 0 frees

Report after the patchset:

ALLOCATIONS
@test.lua:3: 1 events   +32 bytes       -0 bytes
@test.lua:4: 1 events   +24 bytes       -0 bytes

REALLOCATIONS
TRACE [2] started at @test.lua:4: 19 events     +16777336 bytes -8388744 bytes
        Overrides:
                @test.lua:4
                TRACE [2] started at @test.lua:4

DEALLOCATIONS

HEAP SUMMARY:
TRACE [2] started at @test.lua:4 holds 8388576 bytes: 18 allocs, 18 frees
@test.lua:4 holds 40 bytes: 2 allocs, 1 frees
@test.lua:3 holds 32 bytes: 1 allocs, 0 frees