From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Ostanevich <sergos@tarantool.org>, Igor Munkin <imun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH luajit] tools: make memprof parser output user-friendly Date: Fri, 26 Mar 2021 19:48:55 +0300 [thread overview] Message-ID: <20210326164855.30242-1-skaplun@tarantool.org> (raw) Profiler parser output looks like the following: | ALLOCATIONS | @true_memleak.lua:6, line 9: 3 144 0 | @true_memleak.lua:6, line 8: 2 41 0 Line of function definition is confusing for users and looks redundant. Also, these "magic numbers" may shock users. This patch removes lines of function definitions from the output. Info about the line function definition is saved inside symbol info table by field `defined` (it can be used later for a user's custom parser). Moreover, explanatory words and signs are added to numbers for more verbose output. After the patch, profiler parser output looks like the following: | ALLOCATIONS | @true_memleak.lua:9: 3 events +144 bytes -0 bytes | @true_memleak.lua:8: 2 events +41 bytes -0 bytes Resolves tarantool/tarantool#5811 Part of tarantool/tarantool#5657 --- Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-5811-user-friendly-memprof Tarantool branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-5811-user-friendly-memprof Issues: * https://github.com/tarantool/tarantool/issues/5811 * https://github.com/tarantool/tarantool/issues/5657 test/tarantool-tests/misclib-memprof-lapi.test.lua | 4 +++- tools/memprof/humanize.lua | 2 +- tools/utils/symtab.lua | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/tarantool-tests/misclib-memprof-lapi.test.lua b/test/tarantool-tests/misclib-memprof-lapi.test.lua index 1c36c8ab..6aa33198 100644 --- a/test/tarantool-tests/misclib-memprof-lapi.test.lua +++ b/test/tarantool-tests/misclib-memprof-lapi.test.lua @@ -56,7 +56,9 @@ local function fill_ev_type(events, symbols, event_type) } elseif symbols[addr] then ev_type[event.loc.line] = { - name = symbols[addr].name, + name = string.format( + "%s:%d", symbols[addr].name, symbols[addr].defined + ), num = event.num, } end diff --git a/tools/memprof/humanize.lua b/tools/memprof/humanize.lua index 109a39db..2d5814c6 100644 --- a/tools/memprof/humanize.lua +++ b/tools/memprof/humanize.lua @@ -20,7 +20,7 @@ function M.render(events, symbols) for i = 1, #ids do local event = events[ids[i]] - print(string.format("%s: %d\t%d\t%d", + print(string.format("%s: %d events\t+%d bytes\t-%d bytes", symtab.demangle(symbols, event.loc), event.num, event.alloc, diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua index 03aadbd5..6cfa1065 100644 --- a/tools/utils/symtab.lua +++ b/tools/utils/symtab.lua @@ -25,7 +25,8 @@ local function parse_sym_lfunc(reader, symtab) local sym_line = reader:read_uleb128() symtab[sym_addr] = { - name = string_format("%s:%d", sym_chunk, sym_line), + name = sym_chunk, + defined = sym_line, } end @@ -80,7 +81,7 @@ function M.demangle(symtab, loc) end if symtab[addr] then - return string_format("%s, line %d", symtab[addr].name, loc.line) + return string_format("%s:%d", symtab[addr].name, loc.line) end return string_format("CFUNC %#x", addr) -- 2.31.0
next reply other threads:[~2021-03-26 16:49 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-26 16:48 Sergey Kaplun via Tarantool-patches [this message] 2021-03-26 20:33 ` Igor Munkin via Tarantool-patches 2021-03-29 9:46 ` Sergey Kaplun via Tarantool-patches 2021-03-29 11:16 ` Igor Munkin via Tarantool-patches 2021-03-29 13:00 ` Sergey Kaplun via Tarantool-patches 2021-03-29 15:41 ` Sergey Ostanevich via Tarantool-patches 2021-03-29 15:56 ` Sergey Kaplun via Tarantool-patches 2021-03-29 19:11 ` Igor Munkin via Tarantool-patches 2021-03-29 21:58 ` Igor Munkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210326164855.30242-1-skaplun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imun@tarantool.org \ --cc=sergos@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] tools: make memprof parser output user-friendly' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox