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 DB04E9DA743; Wed, 13 Mar 2024 17:41:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DB04E9DA743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1710340916; bh=zBNiyffRkjb8nkH08tPj/4vffqMUNX4s7RZMRqdqOWs=; 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=xNYBvSPEyLMjYcgsEHNhHA6feOqLKkuwQFYwMmUclOcqqSOnK0eJigs5dRNbbGRRE 47oTrhHw3ZJRI6UZJV521l0ktWkQHLuK9Y2QJVXwzuDNE6N/h3/7D+qScIsLCKAH6A 08e8or7SZFSg8MHYmSgdAOWXZL5wJc92dGw00BqQ= Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 22386DC5BB1 for ; Wed, 13 Mar 2024 17:40:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 22386DC5BB1 Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d23114b19dso18352411fa.3 for ; Wed, 13 Mar 2024 07:40:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710340827; x=1710945627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wXi+uUGA2KioG4toE8PT83lyaIRgs2VsrlwVRs5mqVc=; b=HxhD7HlLQDfhGBORS4pzIh6kWLISeglokdOsHQMmJZaeTV0mQRiPQpLQIn7QUjVtyI PHAc7sNfRolhlJ3JX2Vvq0ZZ06i0ifN4MAMF440QL9iFT2LIxINfnFU/DHjf3MGG/sKe rdcpkRLGXkFeNMT4Pq8KzsgrEFFg28zmGlerfYBkpBem6Rqqh5WqIarDpyvtffRHbP94 owjtCoYfY3Tlm5J5EGevvq++ZL3XRczDDYDv0b+Ab3xqUk28zjSQavkKED5ZzGAZ3U4l OZTWyWNE5XCnpNsx03j2fsE0P1UJRgfK/NCBJc8i/bfU1oLM8jR+2mnxltE9/X7HqZEO NRDw== X-Gm-Message-State: AOJu0YyuYFTfm5mCe4WQ/UCMT12VarmHni+PSGx7Eu5pSDXeHQZ5AXsx FTEgT1lDOigasBIi9G0IK0Gita87ZOCuj9H7YcnvoCwoUDM0DAOpk7ufRpx2NSI= X-Google-Smtp-Source: AGHT+IFw2Oe2T+TX1sNiRHSLO+8pSRBN5Un08WN9KxhSZ1l0L6adI/ge7NXvrR+ulGjcu19bOYrUAw== X-Received: by 2002:a2e:9d83:0:b0:2d2:4f81:4dcd with SMTP id c3-20020a2e9d83000000b002d24f814dcdmr4861010ljj.21.1710340826899; Wed, 13 Mar 2024 07:40:26 -0700 (PDT) Received: from localhost.localdomain (95-24-11-149.broadband.corbina.ru. [95.24.11.149]) by smtp.gmail.com with ESMTPSA id a14-20020a2e88ce000000b002d4692a51c8sm505450ljk.99.2024.03.13.07.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:40:26 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, sergeyb@tarantool.org Date: Wed, 13 Mar 2024 17:40:15 +0300 Message-ID: <11449a2e7f83e108e78b527403476bd500b5f6da.1710340671.git.m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v3 3/6] memprof: refactor `heap_chunk` data structure 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" The memprof parser used to have the `heap_chunk` data structure using numeric indices for its values, which is hardly readable and maintainable. This patch replaces these numeric indices with corresponding string keys. Part of tarantool/tarantool#5994 --- tools/memprof/parse.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/memprof/parse.lua b/tools/memprof/parse.lua index 42a601ef..cc66a23e 100644 --- a/tools/memprof/parse.lua +++ b/tools/memprof/parse.lua @@ -45,22 +45,30 @@ local function new_event(loc) } end +local function new_heap_chunk(size, id, loc) + return { + size = size, + id = id, + loc = loc, + } +end + local function link_to_previous(heap_chunk, e, nsize) -- Memory at this chunk was allocated before we start tracking. if heap_chunk then -- Save Lua code location (line) by address (id). - if not e.primary[heap_chunk[2]] then - e.primary[heap_chunk[2]] = { - loc = heap_chunk[3], + if not e.primary[heap_chunk.id] then + e.primary[heap_chunk.id] = { + loc = heap_chunk.loc, allocated = 0, freed = 0, count = 0, } end -- Save information about delta for memory heap. - local location_data = e.primary[heap_chunk[2]] + local location_data = e.primary[heap_chunk.id] location_data.allocated = location_data.allocated + nsize - location_data.freed = location_data.freed + heap_chunk[1] + location_data.freed = location_data.freed + heap_chunk.size location_data.count = location_data.count + 1 end end @@ -95,7 +103,7 @@ local function parse_alloc(reader, asource, events, heap, symbols) e.num = e.num + 1 e.alloc = e.alloc + nsize - heap[naddr] = {nsize, id, loc} + heap[naddr] = new_heap_chunk(nsize, id, loc) end local function parse_realloc(reader, asource, events, heap, symbols) @@ -117,7 +125,7 @@ local function parse_realloc(reader, asource, events, heap, symbols) link_to_previous(heap[oaddr], e, nsize) heap[oaddr] = nil - heap[naddr] = {nsize, id, loc} + heap[naddr] = new_heap_chunk(nsize, id, loc) end local function parse_free(reader, asource, events, heap, symbols) -- 2.44.0