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 421416F3C7; Fri, 26 Mar 2021 19:49:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 421416F3C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616777391; bh=+aK3J/n6MRMFkaJ3klskeUyp23WBz055ifdfo+24bLE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=iB6or36WrpxscIq4qhBhxvYD37mgqHoaRglc63KIRG0JtX4jeHBiI5DyDiSmibUHX RzvNytdyZNRjgAm4/PUD8MGNfQAxPtPzAiZff8qq146hzAAwDx0KnSe1XE7d9P603w e+HH3yvJi0G//G4HA35uvIZZpjYzBYXJCYpHPn0c= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (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 47ED26F3C7 for ; Fri, 26 Mar 2021 19:49:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 47ED26F3C7 Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1lPpef-0001xd-CM; Fri, 26 Mar 2021 19:49:49 +0300 To: Sergey Ostanevich , Igor Munkin Date: Fri, 26 Mar 2021 19:48:55 +0300 Message-Id: <20210326164855.30242-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E3294DD38BE31D7797EF84C856624A09E4809182A05F538085040B05447272D99649DB6BA488826BA45A54590338CB5B401214701D2406E1E82B5 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AED985C8E545F588EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C05E8F374EA5A79AEA1F7E6F0F101C67CDEEF6D7F21E0D1D174C73DBBBFC76648DE988BE098A4CBBAFA11E1739D447C42EDF145ADA69200D389733CBF5DBD5E913377AFFFEAFD269A417C69337E82CC2CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92A417C69337E82CC2CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CFC5EA940A35A165FF2DBA43225CD8A89F890A246B268E114EC6EABA9B74D0DA47B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C5DD32608FC869F5D836E233B752AA5C972FD5B88F52388AD9C2B6934AE262D3EE7EAB7254005DCEDD51BC16B20D219B61E0A4E2319210D9B64D260DF9561598F01A9E91200F654B0279E343DB675BB2F8E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34987A0E8D235BB534E96519A24AF00DEDBEFB3B7AB5D42BA1143E3C5A76B8A3AC442927B67A7AF9801D7E09C32AA3244C6DD829AEB88EE93F1CC69C3B793A0061853296C06374E602927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojapPp7P/VpAgz8zJZ8+uRDg== X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB4075E203A0E6CEDB7EA3022B74DCCEDBAE9B2E1F877ED2670F2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A89437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] tools: make memprof parser output user-friendly 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" 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