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 C818E71224; Wed, 27 Oct 2021 16:56:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C818E71224 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635343001; bh=OjqMhHVIlmhDrGItbmzOJQVLP/0Gn/og8LfC+mL1o4k=; 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=bMfeL8ChcC547r3O9q8HREPX6woYxRzgXn2FBq1tME66/bxc4ZhWBwiwG9KUjIvoN uPL89Q+ied4dW2iT1NHYbpuhh8UhG4ue0GK19Xft5dRiZ92MAxdn8N6xLt2/xUXvyi 6sdQ9Aaz1D/m4C9KzbuCphrGSprZ+ppTlIxkdFqQ= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 7B2A571222 for ; Wed, 27 Oct 2021 16:56:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7B2A571222 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mfjPq-0001BR-Ml; Wed, 27 Oct 2021 16:56:31 +0300 Date: Wed, 27 Oct 2021 16:56:27 +0300 To: Mikhail Shishatskiy Message-ID: <20211027135627.GC8831@tarantool.org> References: <20210929200758.149446-1-m.shishatskiy@tarantool.org> <20210929200758.149446-3-m.shishatskiy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210929200758.149446-3-m.shishatskiy@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D1D35DBD2D15487EB9438C392F7C4E68414DBB3B161A4FBD182A05F53808504009C29860F8A66C864498FD366E30A42A2CA56A389BF4E1D40F46A64A3E3AFBDA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70D278D70F8433719EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637629A2DB6D7098C1B8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8216BCC2AC34473AB21749290F1891276117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B60A9A04DE7321024275ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A55509E27B72FEB4F9B04373EF123799B2EE5E4575F8AA7CA5D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7567C209D01CC1E34B410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B222596F62B8FA9F0A80FC05C21987E1AFC2795E507C48CCCB7AC37F226B69B92A0EE9F788A69511D7E09C32AA3244C5882C84EF8446F9AD6807D57AB6EBF59250262A5EE9971B0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojOHwMx23X6B1w6WLZZzA4Og== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D6BF094741E7B8E766323921C7E3D1B8CA7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v4 2/4] memprof: refactor location parsing 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Misha, Thanks for the patch! Everything is fine in general, but consider a few nits below, please. On 29.09.21, Mikhail Shishatskiy wrote: > As it is hard to keep function `id_location` easily usable in the > function `parse_location` with a growing number of fields in the > table, the code is refactored to make it more understandable. > > The API of module changed with adding a function > `id(loc)` returning the same id-string, as `id_location` did. This > function is useful to "stringify" the location and use it as a key > in the key/value storage. It's worth to also mention that the function need to be used in other modules, hence you've made it public in symtab.lua. > > Part of tarantool/tarantool#5814 > --- > > Issue: https://github.com/tarantool/tarantool/issues/5814 > Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5814-group-allocations-on-trace-by-trace-number > CI: https://github.com/tarantool/tarantool/tree/shishqa/gh-5814-group-allocations-on-trace-by-trace-number > > tools/memprof/parse.lua | 26 +++++++++++++------------- > tools/utils/symtab.lua | 4 ++++ > 2 files changed, 17 insertions(+), 13 deletions(-) > > diff --git a/tools/memprof/parse.lua b/tools/memprof/parse.lua > index 12e2758f..34ff8aef 100644 > --- a/tools/memprof/parse.lua > +++ b/tools/memprof/parse.lua > @@ -8,6 +8,8 @@ local bit = require "bit" > local band = bit.band > local lshift = bit.lshift > > +local symtab = require "utils.symtab" Minor: Why here? It's better either to group all in the one place (worse, IMHO) or just add a new just prior to the part with constants i.e. below caching (better, IMHO). > + > local string_format = string.format > > local LJM_MAGIC = "ljm" > @@ -59,22 +61,20 @@ local function link_to_previous(heap_chunk, e, nsize) > end > end > > -local function id_location(addr, line) > - return string_format("f%#xl%d", addr, line), { > - addr = addr, > - line = line, > - } > -end > - > local function parse_location(reader, asource) > - if asource == ASOURCE_INT then > - return id_location(0, 0) > - elseif asource == ASOURCE_CFUNC then > - return id_location(reader:read_uleb128(), 0) > + local loc = { > + addr = 0, > + line = 0, > + } > + if asource == ASOURCE_CFUNC then > + loc.addr = reader:read_uleb128() > elseif asource == ASOURCE_LFUNC then > - return id_location(reader:read_uleb128(), reader:read_uleb128()) > + loc.addr = reader:read_uleb128() > + loc.line = reader:read_uleb128() > + elseif asource ~= ASOURCE_INT then Minor: It's better to write a separate condition for and a separate block for so-called "default" (i.e. plain "else" block) with an error. So it looks kinda the following: | if asource == ASOURCE_INT then | -- Do nothing. Add a suppression for luacheck here. | elseif asource == ASOURCE_CFUNC then | loc.addr = reader:read_uleb128() | elseif asource == ASOURCE_LFUNC then | loc.addr = reader:read_uleb128() | loc.line = reader:read_uleb128() | else | error("Unknown asource "..asource) | end If you were confused by luacheck, don't worry: just add a suppression for this block. > + error("Unknown asource "..asource) > end > - error("Unknown asource "..asource) > + return symtab.id(loc), loc > end > > local function parse_alloc(reader, asource, events, heap) > > -- > 2.33.0 > -- Best regards, IM