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 1B9C370152; Thu, 2 Dec 2021 14:05:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1B9C370152 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1638443108; bh=fZ7QfXDWpcSnTkqX5lIbJZ4OWYJHJ9Im0J2byXY+xrA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Py416kLK3miaoNO2nhd/cFEbg1RE4k5MiIYMiu/JSrlcn2MFPal56ucC9TH204F9b YcWUne9XdF77lVSKtC7acdLhVVfAz+TtswsGn5g5NkKDCACsQyHDccxIg51WxNSQJR +VO+OosK0UhbVwjMm32ZHo61vuRKvPLYWawkgxCo= 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 27A0671060 for ; Thu, 2 Dec 2021 14:03:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 27A0671060 Received: by smtp17.mail.ru with esmtpa (envelope-from ) id 1msjsK-0005pZ-9A; Thu, 02 Dec 2021 14:03:40 +0300 To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Thu, 2 Dec 2021 14:03:29 +0300 Message-Id: <20211202110329.664738-4-m.shishatskiy@tarantool.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202110329.664738-1-m.shishatskiy@tarantool.org> References: <20211202110329.664738-1-m.shishatskiy@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD97D497884E4742A3C1997752B3D83DC12832A162FABB2E90D182A05F5380850404C228DA9ACA6FE276EFCECFC4ECDAA9C4BEAE0C0B00C43396784B9D07A14AA4EAA8C430F4A77C761 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE721D130CF676D2164EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637993F4D0876F024C68638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8AD16DD5FB05846A419415F8043F25302117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FCF996759079134EB23AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F79006379BAAF22CD2ADBB10D81D268191BDAD3D698AB9A7B718F8C4D1B931868CE1C5781A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F3695E42C86E34F97089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CBD1FC2C1415E7E9D669F24565D0628756000E9711C4B52BB9C2B6934AE262D3EE7EAB7254005DCED114C52B35DBB74F4E7EAB7254005DCEDD827CA74CCEABFF31E0A4E2319210D9B64D260DF9561598F01A9E91200F654B0ECB240A68EBA736F8E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3480A9008907CB2FD081BFFC94A3F79D85525B35E31BF097B4EAC305EEA260344BD0303316BD35F7421D7E09C32AA3244CF27D7A6B221C95EA9D9912254DE15488A90944CA99CF22E3927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMMFVqzO9sR09N2lPmkazfw== X-Mailru-Sender: EFA0F3A8419EF216ABF90D481445BA3F7D98B2F059427A874BEAE0C0B00C43397962F9E9328436E12376072A51849BFFE66B5C1DBFD5D09D5E022D45988A037B448E0EA96F20AB367402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [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: Mikhail Shishatskiy via Tarantool-patches Reply-To: Mikhail Shishatskiy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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". Because of changes mentioned above, the API of changed: now symtab has additional `alias` assotiative table for 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 --- 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) end local dheap = process.form_heap_delta(events, symbols) view.leak_info(dheap) + view.aliases(symbols) os.exit(0) end 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 + print(tostring(lineno).."\t| "..line) + lineno = lineno + 1 + end + print("~\n") + 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 + 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) local symtab = { lfunc = {}, trace = {}, + alias = {}, } local magic = reader:read_octets(3) local version = reader:read_octets(1) @@ -147,15 +155,16 @@ function M.demangle(symtab, loc) end local addr = loc.addr + local epoch = loc.epoch if addr == 0 then return "INTERNAL" end - if symtab.lfunc[addr] and symtab.lfunc[addr][loc.epoch] then - return string_format( - "%s:%d", symtab.lfunc[addr][loc.epoch].source, loc.line - ) + if symtab.lfunc[addr] and symtab.lfunc[addr][epoch] then + local source = symtab.lfunc[addr][epoch].source + local alias = symtab.alias[source] + return string_format("%s:%d", alias or source, loc.line) end return string_format("CFUNC %#x", addr) -- 2.33.1