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 02B0F8BCDDC; Mon, 4 Dec 2023 16:26:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 02B0F8BCDDC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1701696371; bh=TxC2rQAHj8BMhwmlfDIclvj4Cgaos/8oV9v2I8NmpLo=; 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=AtbcOAZkAiGqnRNC/fvHmpBrTKo7B0w+2TJtc2KAJiRYYX3DP93nIbkIGgyacF2sK BlSL9TU5MHzK/Nbr/g+M3hl+1aeeAdds3Jfy7Kyjj03NN/WlFmZFf2CKpKn+IhDE6X 9rSBxMLK7jPrnplWl8Olfa7luB6lSrLahUJjVEWY= Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 3E5A88BCDDC for ; Mon, 4 Dec 2023 16:25:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3E5A88BCDDC Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2c9f413d6b2so19200861fa.1 for ; Mon, 04 Dec 2023 05:25:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701696315; x=1702301115; 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=hps9SciK668OQi/YSGV/2z7gk/Vhzc5YYfD/6lRpeVI=; b=AEK4MtoDlx0/kcyvWwYkLrMGNOB4U7AYW2aD8ZS8bQ1B33NxGSP0VDorfcduTIKt3l CEG25tHVGpCOo3xlMjeEkYeVCnCOc1GB/pS54uleSED8TSbULvU0KVqZm/0I+nc4tx9l aLanaOtSyre+lBMHRwHjR6MLLeoQdhLqhnTox6jy/XoCBFfAwq18g4Vy6pyajy9QFZIy H4zVctm9kcVEiWtX5uzQ/9ejbQyMZuWvAkcRTUWq8/mQpm4wCuXVI4uASw1L399F+gVI mhhXu8oVuCw/Yeck7snQrdTKJZtXS0fm4dYammH7tpPbVWiE7KYvGoZ5qpYBAvQbh20z OrJg== X-Gm-Message-State: AOJu0Yycmflc6X1CfFrjBafNb27LoSH+1V5JAE7MsPvRVY81lWiQCMq8 8yC/id/2PkXywcr+Rx+OJoMWh1vbF1q/tQ== X-Google-Smtp-Source: AGHT+IHrNQHAmDqisSh4tzUg86Aicu9OwNzf5VjJ0iEROKcfW4g4hAP79RaQkTvfXEr0TSjUhxKYcw== X-Received: by 2002:a2e:9113:0:b0:2ca:321:fccb with SMTP id m19-20020a2e9113000000b002ca0321fccbmr516285ljg.91.1701696315408; Mon, 04 Dec 2023 05:25:15 -0800 (PST) Received: from fckxorg.mail.msk ([2a00:1148:b0ba:16:a3e8:bdc1:dbed:dbc8]) by smtp.gmail.com with ESMTPSA id x1-20020a2e9dc1000000b002ca09599e28sm196597ljj.107.2023.12.04.05.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 05:25:14 -0800 (PST) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, sergeyb@tarantool.org Date: Mon, 4 Dec 2023 16:25:00 +0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 2/4] 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.43.0