Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp757719ybg; Wed, 23 Oct 2019 05:33:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBNVNUS2/z62lr0VI3IlQl78SlxEnlSI41qpjvsBLpl0MgSM1Uloq4ORFdSuc/aJsXhPwP X-Received: by 2002:a17:906:218a:: with SMTP id 10mr32786586eju.38.1571833986837; Wed, 23 Oct 2019 05:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571833986; cv=none; d=google.com; s=arc-20160816; b=uuyID2UFxpC9QR9kstSMiGzWWUbgeBFjSo2VRMMOQotQpxroBFUwCkN0BkTrBSSpYm A2ABPjLKtw8lPPnquTsnS+4lnilhOLrmR1F1f9ICebtr2TZdjNQzlQoAScFtSNhfzmzb SUZawJ0Hw9hIdlZwr/Kup6WvdMVOix5ZwerHE0O7g0aEiDyBDB+4Ct/ZVreOqptqNJFO IO6zmGPiPiWd1TUnJ6nQwuExk3+q/oZ7jVs+CFUqH3r4FeuwAwW3SwOymHTTtgNVxpIz 5c9TBfNTounmzMX4OjdU5gGFiYxOpC4D9U7J64/DSZi4ZPiEf+dM1ID39FelbApbinwB C4VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5tE2qxKuRoQ65SeNdqSXlQHhj4ytxFyFwuU50BxgQmA=; b=kseKHaQNhzVIyzKbNTwrjyH7pEE2OgyKMgnbnDRvBVZf4HbZ6/GMx3R9e7tilknZeP Jj9wBv80KoABhnkmL7QTrOWfmeD7jo5lZVOFJJvakITSMU9KpIvy/KSTqc5a9fJqFOyh zGgaR5SPwYLZJgU9lyxGOGs8qMwrehpGeGpav2OzGt5toqTOmW/BALujx2MHS1MSioCi cnl95iWvIDO7d7FZB7ZdR/9lsk2TDhREgHJEdu86GrXQeDIdq04UeNrdCeEJ/wZKsCZQ KJpjXBm+wTaEj4K6gkjRVD9ZJblKpohifX+49hDizBKgqsQeuvJ8asAy71A3li0mJF7E 2IVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EkSY+eDj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 13si16253326edw.357.2019.10.23.05.32.43; Wed, 23 Oct 2019 05:33:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EkSY+eDj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389989AbfJWHz2 (ORCPT + 99 others); Wed, 23 Oct 2019 03:55:28 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32618 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732328AbfJWHz1 (ORCPT ); Wed, 23 Oct 2019 03:55:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571817326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5tE2qxKuRoQ65SeNdqSXlQHhj4ytxFyFwuU50BxgQmA=; b=EkSY+eDjnc+c3XzrHyjIBS02HKBStQiBqP+rg6XhcYWzQkXpdXcCiiIshsL9n8a3EopxEc jj6kAmOTN4PcWVbU04YgXkYJrTvLEP889DMm9StoncByRcNpMU57l8w0V3xcS9yjN0i9PN BuPlHDLVuA7WQt1yZROaK3YiDjoe844= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-hbGI3oQxNXiou5RsCuVd6w-1; Wed, 23 Oct 2019 03:55:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62850107AD31; Wed, 23 Oct 2019 07:55:21 +0000 (UTC) Received: from krava (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with SMTP id 05B765DD78; Wed, 23 Oct 2019 07:55:18 +0000 (UTC) Date: Wed, 23 Oct 2019 09:55:17 +0200 From: Jiri Olsa To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Andi Kleen , Stephane Eranian , Jin Yao , Alexey Budankov Subject: Re: [PATCHv2 0/2] perf tools: Share struct map after clone Message-ID: <20191023075517.GA22919@krava> References: <20191016082226.10325-1-jolsa@kernel.org> MIME-Version: 1.0 In-Reply-To: <20191016082226.10325-1-jolsa@kernel.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: hbGI3oQxNXiou5RsCuVd6w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >=20 > This 'maps sharing' seems to save lot of heap for reports with > many forks/cloned mmaps (over 60% in example below). >=20 > Profile kernel build: >=20 > $ perf record make -j 40 >=20 > Get heap profile (tools/perf directory): >=20 > $ > $ make TCMALLOC=3D1 > $ HEAPPROFILE=3D/tmp/heapprof ./perf report -i perf.data --stdio > out > $ pprof ./perf /tmp/heapprof.000* >=20 > Before: >=20 > (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 >=20 > After: >=20 > (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 >=20 > v2 changes: > - rebased to Arnaldo's perf/core > - patch 1 already taken >=20 > 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 jirka