Re: [PATCHv2 0/2] perf tools: Share struct map after clone

From: Jiri Olsa
Date: Mon Nov 18 2019 - 07:14:11 EST


On Tue, Oct 29, 2019 at 09:58:55PM +0100, Jiri Olsa wrote:
> On Wed, Oct 23, 2019 at 09:55:17AM +0200, Jiri Olsa wrote:
> > On Wed, Oct 16, 2019 at 10:22:24AM +0200, Jiri Olsa wrote:
> > > hi,
> > > Andi reported that maps cloning is eating lot of memory and
> > > it's probably unnecessary, because they keep the same data.
> > >
> > > This 'maps sharing' seems to save lot of heap for reports with
> > > many forks/cloned mmaps (over 60% in example below).
> > >
> > > Profile kernel build:
> > >
> > > $ perf record make -j 40
> > >
> > > Get heap profile (tools/perf directory):
> > >
> > > $ <install gperftools>
> > > $ make TCMALLOC=1
> > > $ HEAPPROFILE=/tmp/heapprof ./perf report -i perf.data --stdio > out
> > > $ pprof ./perf /tmp/heapprof.000*
> > >
> > > Before:
> > >
> > > (pprof) top
> > > Total: 2335.5 MB
> > > 1735.1 74.3% 74.3% 1735.1 74.3% memdup
> > > 402.0 17.2% 91.5% 402.0 17.2% zalloc
> > > 140.2 6.0% 97.5% 145.8 6.2% map__new
> > > 33.6 1.4% 98.9% 33.6 1.4% symbol__new
> > > 12.4 0.5% 99.5% 12.4 0.5% alloc_event
> > > 6.2 0.3% 99.7% 6.2 0.3% nsinfo__new
> > > 5.5 0.2% 100.0% 5.5 0.2% nsinfo__copy
> > > 0.3 0.0% 100.0% 0.3 0.0% dso__new
> > > 0.1 0.0% 100.0% 0.1 0.0% do_read_string
> > > 0.0 0.0% 100.0% 0.0 0.0% __GI__IO_file_doallocate
> > >
> > > After:
> > >
> > > (pprof) top
> > > Total: 784.5 MB
> > > 385.8 49.2% 49.2% 385.8 49.2% memdup
> > > 285.8 36.4% 85.6% 285.8 36.4% zalloc
> > > 80.4 10.3% 95.9% 83.7 10.7% map__new
> > > 19.1 2.4% 98.3% 19.1 2.4% symbol__new
> > > 6.2 0.8% 99.1% 6.2 0.8% alloc_event
> > > 3.6 0.5% 99.6% 3.6 0.5% nsinfo__new
> > > 3.2 0.4% 100.0% 3.2 0.4% nsinfo__copy
> > > 0.2 0.0% 100.0% 0.2 0.0% dso__new
> > > 0.0 0.0% 100.0% 0.0 0.0% do_read_string
> > > 0.0 0.0% 100.0% 0.0 0.0% elf_fill
> > >
> > > v2 changes:
> > > - rebased to Arnaldo's perf/core
> > > - patch 1 already taken
> > >
> > > Also available in here:
> > > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> > > perf/map_shared
> >
> > I rebased to latest perf/core and pushed the branch out
>
> rebased and pushed out

heya,
I lost track of this.. what's the status, are you going with your
version, or is this one still in? I don't see any of them in latest
code..

thanks,
jirka