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 24688727D0E; Wed, 6 Dec 2023 21:56:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 24688727D0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1701889019; 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=nzmB6n+oLv2jU9/jLRBv4uiS6v9pTn1e9cCikXQC2hFjnq/N/bOb8OhQTWUeyh6DH AbSihM63ER5dQMphw1kIFQJfCf7ehW9FarVRpTXvftEoBMGpgwy7xQoxKn4cbfQrNC rxj4RwU3PGwANYVtgxh6KU5V9jDsTUF5N+Qh37Y8= Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 3EB6A727D0F for ; Wed, 6 Dec 2023 21:55:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3EB6A727D0F Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-50c02628291so149661e87.0 for ; Wed, 06 Dec 2023 10:55:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701888936; x=1702493736; 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=vkyWIZgZ5mix5x2ZfoOayfHcxuYCQHVK5X3CytV4CxBEmn1CsshEhaEEZwo5V6eNRQ +7kdoqelZgPkZgzXM8nli8bp8JUqu2tmyMMZTzy17Ar0UfVvocMf+qn+9L4QHyJ+ljJ6 lS2ld4Ah33aV9nvZ7v6AqZjrEzNaqhk1j9Ok5s+YJxu3tPEmtsFpO2Z9hR15IJcRhm6T ukBXzv7FQAiEKkAKpdmyttWFfcJ+kjkImcS8U3k6YezNRy9Gr/DVsx1Ij1ws9Nx7rjvD 1VVYl9/FJ2lv2xk9/em07X8tfha7VzCx8WKOIVhx05rBvgXA8HEpps/9GNuX76+4DxyK yGwQ== X-Gm-Message-State: AOJu0YzJ1penJYpCdTw4kKez2WsusyL17OHeoSEVH+i1KtArjvG59Yig C0g9RQlJA/xdLf713sFoS1Ze/93A9DoDmg== X-Google-Smtp-Source: AGHT+IEhiwIMuOpFoE3LXy18oQaTEv0bjX5nBJGywlYABmcsYbGyULd860n9tSVH3Gapb7XDsvPTsA== X-Received: by 2002:a05:6512:3ba5:b0:50b:eab5:d70d with SMTP id g37-20020a0565123ba500b0050beab5d70dmr986292lfv.11.1701888936374; Wed, 06 Dec 2023 10:55:36 -0800 (PST) Received: from localhost.localdomain (95-24-1-238.broadband.corbina.ru. [95.24.1.238]) by smtp.gmail.com with ESMTPSA id t23-20020a199117000000b0050c0320f167sm606367lfd.245.2023.12.06.10.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 10:55:36 -0800 (PST) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, sergeyb@tarantool.org Date: Wed, 6 Dec 2023 21:55:18 +0300 Message-ID: <5ce5e302337b09286e7afb66104c9380b68de84f.1701888856.git.m.kokryashkin@tarantool.org> 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 v2 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.43.0