From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [94.100.177.90]) (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 D44DF4765E0 for ; Mon, 28 Dec 2020 09:29:13 +0300 (MSK) Date: Mon, 28 Dec 2020 09:28:27 +0300 From: Sergey Kaplun Message-ID: <20201228062827.GL14702@root> References: <03ac70e3bfb9bf7061ad71c1bac50ed3f8e853fc.1608907726.git.skaplun@tarantool.org> <20201226225651.GI5396@tarantool.org> <20201227071656.GA9101@root> <20201228053027.GK14702@root> <20201228053306.GQ5396@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201228053306.GQ5396@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH luajit v2 7/7] tools: introduce a memory profile parser List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org This is a patch for workaround of Tarantool's work with builtins. It is necessary to be able launch profiler parser something like this (with Tarantool only): | src/tarantool -e 'require"memprof"(arg[1])' - ~/tmp/uj_memprof/memprof_new.bin Branch is force-pushed. =================================================================== diff --git a/tools/memprof.lua b/tools/memprof.lua index a98e192..9f96208 100644 --- a/tools/memprof.lua +++ b/tools/memprof.lua @@ -90,22 +90,30 @@ local function parseargs(args) return args[args.argn] end -local inputfile = parseargs(arg) +local function dump(inputfile) + local reader = bufread.new(inputfile) + local symbols = symtab.parse(reader) + local events = memprof.parse(reader, symbols) -local reader = bufread.new(inputfile) -local symbols = symtab.parse(reader) -local events = memprof.parse(reader, symbols) + stdout:write("ALLOCATIONS", "\n") + view.render(events.alloc, symbols) + stdout:write("\n") -stdout:write("ALLOCATIONS", "\n") -view.render(events.alloc, symbols) -stdout:write("\n") + stdout:write("REALLOCATIONS", "\n") + view.render(events.realloc, symbols) + stdout:write("\n") -stdout:write("REALLOCATIONS", "\n") -view.render(events.realloc, symbols) -stdout:write("\n") + stdout:write("DEALLOCATIONS", "\n") + view.render(events.free, symbols) + stdout:write("\n") -stdout:write("DEALLOCATIONS", "\n") -view.render(events.free, symbols) -stdout:write("\n") + os.exit(0) +end -os.exit(0) +-- FIXME: this script should be application-independent. +local args = {...} +if #args == 1 and args[1] == "memprof" then + return dump +else + dump(parseargs(args)) +end =================================================================== -- Best regards, Sergey Kaplun