Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Mikhail Shishatskiy <m.shishatskiy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit v2 3/3] memprof: substitute long proto names with aliases
Date: Tue, 25 Jan 2022 13:12:05 +0300	[thread overview]
Message-ID: <Ye/M9UNNoKcRlD0y@root> (raw)
In-Reply-To: <20211202110329.664738-4-m.shishatskiy@tarantool.org>

Hi, Mikhail!

Thanks for the patch!

May be it is more user-friendly to use the first line of alias instead
strict "function_alias_\d"? Something like:
| \d string "print(nil)..."#N:

\d here is the number of alias.
#N -- linenumber.

Also this simplifies reading for oneline functions without \n.

Thoughts?
But I'm OK with the current version.

LGTM, otherwise, except a few nits below.

On 02.12.21, Mikhail Shishatskiy wrote:
> Sometimes a loaded chunk name can be multiline (actually, it
> is the Lua code itself). In order not to burden memprof parser
> output with big multiline names, aliases were introduced.
> 
> The chunk name is replaced by `function_alias_N` (where N is a unique id)
> to be displayed in the allocation events report. All the aliases are
> printed in the end of parser's output under the header "ALIASES".

Typo: s/in/at/
Typo: s/parser's/the parsers/

> 
> Because of changes mentioned above, the API of <utils/symtab.lua>
> changed: now symtab has additional `alias` assotiative table for

Typo: s/assotiative/associative/

> storing aliases: one can get alias string by sym_chunk key and sym_chunk
> by alias index. The humanizer module now can display aliases with the
> new function <aliases>.
> 
> Follows up tarantool/tarantool#5815

Nit: "Part of" looks more properly.

> ---
> 
> Issue: https://github.com/tarantool/tarantool/issues/5815
> Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5815-enrich-symtab-when-prototype-is-allocated-v2
> Tarantool branch: https://github.com/tarantool/tarantool/tree/shishqa/gh-5815-enrich-symtab-when-prototype-is-allocated
> 
>  tools/memprof.lua          |  1 +
>  tools/memprof/humanize.lua | 14 ++++++++++++++
>  tools/utils/symtab.lua     | 17 +++++++++++++----
>  3 files changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/memprof.lua b/tools/memprof.lua
> index 18b44fdd..cf66dd9e 100644
> --- a/tools/memprof.lua
> +++ b/tools/memprof.lua
> @@ -106,6 +106,7 @@ local function dump(inputfile)

<snipped>

> diff --git a/tools/memprof/humanize.lua b/tools/memprof/humanize.lua
> index 7771005d..d77c7132 100644
> --- a/tools/memprof/humanize.lua
> +++ b/tools/memprof/humanize.lua
> @@ -81,4 +81,18 @@ function M.leak_info(dheap)
>    print("")
>  end
>  
> +function M.aliases(symbols)
> +  if #symbols.alias == 0 then return end
> +  print("ALIASES:")
> +  for _, source in ipairs(symbols.alias) do
> +    print(symbols.alias[source]..":")
> +    local lineno = 1
> +    for line in source:gmatch("(.-)\n") do

The last line may be without \n symbol and will be skipped.
For example the following chunk

| $ src/luajit -e '
|   misc.memprof.start("/tmp/test_memprof.bin")
|   loadstring"\n\nfor i = 1, 1e3 do _ = {i = string.rep(i, 12)} end"()
|   misc.memprof.stop()
| '

will report:

| function_alias_1:
| 1       | 
| 2       | 
| ~

> +      print(tostring(lineno).."\t| "..line)
> +      lineno = lineno + 1
> +    end
> +    print("~\n")

Do we need this '~' symbol?

> +  end
> +end
> +
>  return M
> diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua
> index 00bab03a..133a0fc7 100644
> --- a/tools/utils/symtab.lua
> +++ b/tools/utils/symtab.lua
> @@ -46,6 +46,13 @@ function M.parse_sym_lfunc(reader, symtab)
>      symtab.lfunc[sym_addr] = {}
>    end
>  
> +  if sym_chunk:find('\n') and symtab.alias[sym_chunk] == nil then

Nit: `and not symtab.alias[sym_chunk]` looks more in Lua way for me.
Fill free to ignore.

> +    table.insert(symtab.alias, sym_chunk)
> +    symtab.alias[sym_chunk] = string_format(
> +      "function_alias_%d", #symtab.alias
> +    )
> +  end
> +
>    table.insert(symtab.lfunc[sym_addr], {
>      source = sym_chunk,
>      linedefined = sym_line,
> @@ -77,6 +84,7 @@ function M.parse(reader)

<snipped>

> -- 
> 2.33.1
> 

-- 
Best regards,
Sergey Kaplun

  reply	other threads:[~2022-01-25 10:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 11:03 [Tarantool-patches] [PATCH luajit v2 0/3] memprof: enrich symtab when meeting new prototype Mikhail Shishatskiy via Tarantool-patches
2021-12-02 11:03 ` [Tarantool-patches] [PATCH luajit v2 1/3] memprof: add symbol epochs Mikhail Shishatskiy via Tarantool-patches
2022-03-15  7:56   ` Sergey Kaplun via Tarantool-patches
2021-12-02 11:03 ` [Tarantool-patches] [PATCH luajit v2 2/3] memprof: enrich symtab when meeting new prototype Mikhail Shishatskiy via Tarantool-patches
2022-01-19 16:56   ` Mikhail Shishatskiy via Tarantool-patches
2022-01-25  8:14     ` Sergey Kaplun via Tarantool-patches
2021-12-02 11:03 ` [Tarantool-patches] [PATCH luajit v2 3/3] memprof: substitute long proto names with aliases Mikhail Shishatskiy via Tarantool-patches
2022-01-25 10:12   ` Sergey Kaplun via Tarantool-patches [this message]
2022-04-12 14:30 ` [Tarantool-patches] [PATCH luajit v2 0/3] memprof: enrich symtab when meeting new prototype Igor Munkin 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=Ye/M9UNNoKcRlD0y@root \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.shishatskiy@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v2 3/3] memprof: substitute long proto names with aliases' \
    /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