From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C0B286F879; Tue, 25 Jan 2022 13:14:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C0B286F879 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1643105646; bh=V0lkKGOZ7bRQIGz7tG0mPqBhRPwaOlAURsDtypdfaE8=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=B7e7e3x+0o4qcQXnzhFFBlfV0N97PBbSprmmNUWYu0qp4dHCtLQ4kEACJOng0g9Ja erpnQGZ251E3VuuVvHqyif6Jj+9NJqxCLxCxgT1IiJNc3kpRR1ZvYA0fRn93VHncNS ih65QC8RlVnrdQwrHiCiunHpkohdayxsc9dpDrG4= Received: from smtp17.mail.ru (smtp17.mail.ru [94.100.176.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9E9936F879 for ; Tue, 25 Jan 2022 13:14:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9E9936F879 Received: by smtp17.mail.ru with esmtpa (envelope-from ) id 1nCIpv-0005Fm-PB; Tue, 25 Jan 2022 13:14:04 +0300 Date: Tue, 25 Jan 2022 13:12:05 +0300 To: Mikhail Shishatskiy Message-ID: References: <20211202110329.664738-1-m.shishatskiy@tarantool.org> <20211202110329.664738-4-m.shishatskiy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211202110329.664738-4-m.shishatskiy@tarantool.org> X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9AA78FDF62ECAE61F7A922168D8AD45D749A6A71140E6560E182A05F538085040E3C264D80B4AB27C94CC996BFF446BD984ADE5E15638846291908B033A9C06CA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F2EC3597058CFA6DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BEEB0D1ADA650026EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BEBC5CAB6D411FFA6A08E717307A8BB8A30168696E97295B7CC7F00164DA146DAFE8445B8C89999728AA50765F790063783E00425F71A4181389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8EDCF5861DED71B2F389733CBF5DBD5E9B5C8C57E37DE458B9E9CE733340B9D5F3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735D2D576BCF940C736C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A571843CF2BEE5B4D14E003CBFAF8E4B56161BECEB59113A14D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75913C2247C57F08EB410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3455AC8BF8E3153BA0AF73C953BCA535D95573750D5D70E18EF0D53CF2DD8E5EAAF5B37C4F3A36051B1D7E09C32AA3244C86D93A14EFDAE64F6EDAC0B0B9800FC0795D98D676DD64D0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojF0Kx79yI7sWWr6naM8uzxg== X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB4D0C28A6F163238E93902DB45F648F8629F2D44110AAA01A7F2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A84198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2 3/3] memprof: substitute long proto names with aliases X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Mikhail! Thanks for the patch! May be it is more user-friendly to use the first line of alias instead strict "function_alias_\d"? Something like: | \d string "print(nil)..."#N: \d here is the number of alias. #N -- linenumber. Also this simplifies reading for oneline functions without \n. Thoughts? But I'm OK with the current version. LGTM, otherwise, except a few nits below. On 02.12.21, Mikhail Shishatskiy wrote: > Sometimes a loaded chunk name can be multiline (actually, it > is the Lua code itself). In order not to burden memprof parser > output with big multiline names, aliases were introduced. > > The chunk name is replaced by `function_alias_N` (where N is a unique id) > to be displayed in the allocation events report. All the aliases are > printed in the end of parser's output under the header "ALIASES". Typo: s/in/at/ Typo: s/parser's/the parsers/ > > Because of changes mentioned above, the API of > changed: now symtab has additional `alias` assotiative table for Typo: s/assotiative/associative/ > storing aliases: one can get alias string by sym_chunk key and sym_chunk > by alias index. The humanizer module now can display aliases with the > new function . > > Follows up tarantool/tarantool#5815 Nit: "Part of" looks more properly. > --- > > Issue: https://github.com/tarantool/tarantool/issues/5815 > Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5815-enrich-symtab-when-prototype-is-allocated-v2 > Tarantool branch: https://github.com/tarantool/tarantool/tree/shishqa/gh-5815-enrich-symtab-when-prototype-is-allocated > > tools/memprof.lua | 1 + > tools/memprof/humanize.lua | 14 ++++++++++++++ > tools/utils/symtab.lua | 17 +++++++++++++---- > 3 files changed, 28 insertions(+), 4 deletions(-) > > diff --git a/tools/memprof.lua b/tools/memprof.lua > index 18b44fdd..cf66dd9e 100644 > --- a/tools/memprof.lua > +++ b/tools/memprof.lua > @@ -106,6 +106,7 @@ local function dump(inputfile) > diff --git a/tools/memprof/humanize.lua b/tools/memprof/humanize.lua > index 7771005d..d77c7132 100644 > --- a/tools/memprof/humanize.lua > +++ b/tools/memprof/humanize.lua > @@ -81,4 +81,18 @@ function M.leak_info(dheap) > print("") > end > > +function M.aliases(symbols) > + if #symbols.alias == 0 then return end > + print("ALIASES:") > + for _, source in ipairs(symbols.alias) do > + print(symbols.alias[source]..":") > + local lineno = 1 > + for line in source:gmatch("(.-)\n") do The last line may be without \n symbol and will be skipped. For example the following chunk | $ src/luajit -e ' | misc.memprof.start("/tmp/test_memprof.bin") | loadstring"\n\nfor i = 1, 1e3 do _ = {i = string.rep(i, 12)} end"() | misc.memprof.stop() | ' will report: | function_alias_1: | 1 | | 2 | | ~ > + print(tostring(lineno).."\t| "..line) > + lineno = lineno + 1 > + end > + print("~\n") Do we need this '~' symbol? > + end > +end > + > return M > diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua > index 00bab03a..133a0fc7 100644 > --- a/tools/utils/symtab.lua > +++ b/tools/utils/symtab.lua > @@ -46,6 +46,13 @@ function M.parse_sym_lfunc(reader, symtab) > symtab.lfunc[sym_addr] = {} > end > > + if sym_chunk:find('\n') and symtab.alias[sym_chunk] == nil then Nit: `and not symtab.alias[sym_chunk]` looks more in Lua way for me. Fill free to ignore. > + table.insert(symtab.alias, sym_chunk) > + symtab.alias[sym_chunk] = string_format( > + "function_alias_%d", #symtab.alias > + ) > + end > + > table.insert(symtab.lfunc[sym_addr], { > source = sym_chunk, > linedefined = sym_line, > @@ -77,6 +84,7 @@ function M.parse(reader) > -- > 2.33.1 > -- Best regards, Sergey Kaplun