From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A54CA4765E0 for ; Mon, 28 Dec 2020 10:01:23 +0300 (MSK) From: Sergey Kaplun Date: Mon, 28 Dec 2020 10:00:36 +0300 Message-Id: <20201228070036.29637-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-discussions] [PATCH] build: embed LuaJIT memory profiler tools List-Id: Tarantool development process List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin , Sergey Ostanevich Cc: tarantool-discussions@dev.tarantool.org This patch embeds a parser for binary data dumped via the memory profiler to Tarantool binary. It is a set of the following Lua modules: * utils/bufread.lua: read binary data from a file. * utils/symtab.lua: symbol table decode functions * memprof/parse.lua: decode the memory profiler event stream * memprof/humanize.lua: display decoded data in human readable format * memprof.lua: Lua script and module to display data It launch with the following command: $ tarantool -e 'require("memprof")(arg[1])' - filename.bin Closed #5490 --- Issue: https://github.com/tarantool/tarantool/issues/5490 Branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-5442-luajit-memory-profiler CI: https://gitlab.com/tarantool/tarantool/-/commits/skaplun/gh-5442-luajit-memory-profiler src/CMakeLists.txt | 6 ++++++ src/lua/init.c | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b95688c1a..9a712bc29 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,6 +61,12 @@ lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/vmdef.lua lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/v.lua") lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/p.lua") lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/zone.lua") +# LuaJIT tools.* library +lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/memprof.lua") +lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/memprof/humanize.lua") +lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/memprof/parse.lua") +lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/utils/bufread.lua") +lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/tools/utils/symtab.lua") add_custom_target(generate_lua_sources WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/box diff --git a/src/lua/init.c b/src/lua/init.c index a0b2fc775..82075c595 100644 --- a/src/lua/init.c +++ b/src/lua/init.c @@ -121,7 +121,14 @@ extern char strict_lua[], string_lua[], swim_lua[], p_lua[], /* LuaJIT 2.1 profiler */ - zone_lua[] /* LuaJIT 2.1 profiler */; + zone_lua[], /* LuaJIT 2.1 profiler */ + /* tools.* libraries. */ + bufread_lua[], + symtab_lua[], + parse_lua[], + humanize_lua[], + memprof_lua[] +; static const char *lua_modules[] = { /* Make it first to affect load of all other modules */ @@ -167,6 +174,12 @@ static const char *lua_modules[] = { /* Profiler */ "jit.p", p_lua, "jit.zone", zone_lua, + /* tools.* libraries. Order is important. */ + "utils.bufread", bufread_lua, + "utils.symtab", symtab_lua, + "memprof.parse", parse_lua, + "memprof.humanize", humanize_lua, + "memprof", memprof_lua, NULL }; -- 2.28.0