[Tarantool-patches] [PATCH luajit v7] memprof: introduce cli flag to run dump parser
Sergey Bronnikov
sergeyb at tarantool.org
Tue Jul 11 16:06:18 MSK 2023
Hello, Max!
Thanks for the patch! See my comments.
Sergey
On 7/10/23 14:24, Maksim Kokryashkin wrote:
> From: Maxim Kokryashkin <m.kokryashkin at tarantool.org>
>
> It is really inconvenient to use a standalone shell script to parse
> memprof dump. That is why this commit introduces a CLI flag for tools
> to the LuaJIT, so now it is possible to parse memprof dump
> as simple as:
> ```
> luajit -tm memprof.bin
> ```
>
> Closes tarantool/tarantool#5688
> ---
> Changes in v7:
> - Fixed comments as per review by Sergey
>
> Branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5688-cli-for-memprof-parse
> PR: https://github.com/tarantool/tarantool/pull/8002
>
> src/luajit.c | 32 +++++++++-
> .../gh-5688-memprof-cli-flag.test.lua | 58 +++++++++++++++++++
> 2 files changed, 89 insertions(+), 1 deletion(-)
> create mode 100644 test/tarantool-tests/gh-5688-memprof-cli-flag.test.lua
>
> diff --git a/src/luajit.c b/src/luajit.c
> index 1ca24301..d335f32b 100644
> --- a/src/luajit.c
> +++ b/src/luajit.c
> @@ -72,6 +72,7 @@ static void print_usage(void)
> " -O[opt] Control LuaJIT optimizations.\n"
> " -i Enter interactive mode after executing " LUA_QL("script") ".\n"
> " -v Show version information.\n"
> + " -t[cmd] Execute tool.\n"
According to usage cmd after -t option is optional. However without cmd
luajit prints usage
that hints about incorrect usage:
[0] ~/sources/MRG/tarantool/third_party/luajit$ ./src/luajit -t
usage: ./src/luajit [options]... [script [args]...].
Available options are:
-e chunk Execute string 'chunk'.
-l name Require library 'name'.
-b ... Save or list bytecode.
-j cmd Perform LuaJIT control command.
-O[opt] Control LuaJIT optimizations.
-i Enter interactive mode after executing 'script'.
-v Show version information.
-t[cmd] Execute tool.
-E Ignore environment variables.
-- Stop handling options.
- Execute stdin and stop handling options.
<snipped>
> +end
> +
> +generate_output(TMP_BINFILE, default_payload)
> +
> +local errcode = os.execute(EXECUTABLE .. ' -tinvalid ' .. TMP_BINFILE)
> +test:ok(errcode ~= 0, 'invalid tool flag')
> +
> +errcode = os.execute(EXECUTABLE .. ' -tm ' .. BAD_PATH)
> +test:ok(errcode ~= 0, 'binfile does not exist')
> +
> +errcode = os.execute(EXECUTABLE .. ' -tm ' .. TMP_BINFILE)
> +test:ok(errcode == 0, 'memprof binfile parsing')
Nit: probably it is worth adding checks for output.
> +
> +os.remove(TMP_BINFILE)
> +os.exit(test:check() and 0 or 1)
> --
> 2.39.2 (Apple Git-143)
>
More information about the Tarantool-patches
mailing list