From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, sergeyb@tarantool.org Subject: [Tarantool-patches] [PATCH luajit v2 3/6] memprof: refactor `heap_chunk` data structure Date: Wed, 6 Dec 2023 21:55:18 +0300 [thread overview] Message-ID: <5ce5e302337b09286e7afb66104c9380b68de84f.1701888856.git.m.kokryashkin@tarantool.org> (raw) In-Reply-To: <cover.1701888856.git.m.kokryashkin@tarantool.org> 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
next prev parent reply other threads:[~2023-12-06 18:56 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-06 18:55 [Tarantool-patches] [PATCH luajit v2 0/6] profilers: refactor parsers Maxim Kokryashkin via Tarantool-patches 2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 1/6] build: purge sysprof.collapse module Maxim Kokryashkin via Tarantool-patches 2023-12-12 10:18 ` Sergey Kaplun via Tarantool-patches 2023-12-19 12:20 ` Sergey Bronnikov via Tarantool-patches 2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 2/6] build: fix tool components handling Maxim Kokryashkin via Tarantool-patches 2023-12-12 10:32 ` Sergey Kaplun via Tarantool-patches 2023-12-12 12:53 ` Maxim Kokryashkin via Tarantool-patches 2023-12-12 12:51 ` Sergey Kaplun via Tarantool-patches 2023-12-19 13:56 ` Sergey Bronnikov via Tarantool-patches 2023-12-06 18:55 ` Maxim Kokryashkin via Tarantool-patches [this message] 2023-12-12 10:34 ` [Tarantool-patches] [PATCH luajit v2 3/6] memprof: refactor `heap_chunk` data structure Sergey Kaplun via Tarantool-patches 2023-12-19 14:00 ` Sergey Bronnikov via Tarantool-patches 2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 4/6] memprof: remove unused arguments Maxim Kokryashkin via Tarantool-patches 2023-12-12 10:44 ` Sergey Kaplun via Tarantool-patches 2023-12-19 14:01 ` Sergey Bronnikov via Tarantool-patches 2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 5/6] memprof: introduce the `--human-readable` option Maxim Kokryashkin via Tarantool-patches 2023-12-12 10:54 ` Sergey Kaplun via Tarantool-patches 2023-12-20 12:24 ` Sergey Bronnikov via Tarantool-patches 2023-12-06 18:55 ` [Tarantool-patches] [PATCH luajit v2 6/6] profilers: print user-friendly errors Maxim Kokryashkin via Tarantool-patches 2023-12-12 11:51 ` Sergey Kaplun via Tarantool-patches 2023-12-12 12:54 ` Maxim Kokryashkin via Tarantool-patches 2023-12-12 12:54 ` Sergey Kaplun via Tarantool-patches 2023-12-29 12:27 ` Sergey Bronnikov via Tarantool-patches 2024-01-09 13:54 ` Maxim Kokryashkin via Tarantool-patches 2024-01-16 9:48 ` Sergey Bronnikov via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=5ce5e302337b09286e7afb66104c9380b68de84f.1701888856.git.m.kokryashkin@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=max.kokryashkin@gmail.com \ --cc=sergeyb@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit v2 3/6] memprof: refactor `heap_chunk` data structure' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox