From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 8AC6B4765E0 for ; Mon, 28 Dec 2020 09:31:48 +0300 (MSK) Date: Mon, 28 Dec 2020 09:31:42 +0300 From: Igor Munkin Message-ID: <20201228063142.GR5396@tarantool.org> References: <03ac70e3bfb9bf7061ad71c1bac50ed3f8e853fc.1608907726.git.skaplun@tarantool.org> <20201226225651.GI5396@tarantool.org> <20201227071656.GA9101@root> <20201228053027.GK14702@root> <20201228053306.GQ5396@tarantool.org> <20201228062827.GL14702@root> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201228062827.GL14702@root> 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: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Sergey, On 28.12.20, Sergey Kaplun wrote: > 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 Heck this. Still LGTM :) > > 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 -- Best regards, IM