From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115778 invoked by alias); 25 Nov 2019 14:47:33 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 115769 invoked by uid 89); 25 Nov 2019 14:47:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx1.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [committed] Use actual die count in read_multifile mode Message-ID: <20191125144726.GA7139@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-q4/txt/msg00075.txt.bz2 Hi, With a debug patch added, we can see the following trace: ... $ cp hello 1; cp 1 2; dwz -m 3 1 2 --devel-trace Compressing 1 Used estimated number of dies of 72 for off_htab allocation Write-multifile 1 Compressing 2 Used estimated number of dies of 72 for off_htab allocation Write-multifile 2 Optimize-multifile Read-multifile Used estimated number of dies of 53 for off_htab allocation Compressing 1 in finalize-multifile mode Using die count 73 for off_htab allocation Compressing 2 in finalize-multifile mode Using die count 73 for off_htab allocation ... However, in read-multifile mode, there's no need to estimate the number of DIEs, since we write the file during optimize-multifile mode and can keep track of the number of DIEs. So, in read-multifile, use actual DIE count, rather than an estimate for off_htab allocation. In combination with the same debug patch, this gives us: ... $ cp hello 1; cp 1 2; dwz -m 3 1 2 --devel-trace Compressing 1 Used estimated number of dies of 72 for off_htab allocation Write-multifile 1 Compressing 2 Used estimated number of dies of 72 for off_htab allocation Write-multifile 2 Optimize-multifile Read-multifile -Used estimated number of dies of 53 for off_htab allocation +Using die count 72 for off_htab allocation Compressing 1 in finalize-multifile mode Using die count 73 for off_htab allocation Compressing 2 in finalize-multifile mode Using die count 73 for off_htab allocation ... Committed to trunk. Thanks, - Tom Use actual die count in read_multifile mode 2019-11-25 Tom de Vries * dwz.c (optimize_multifile, read_multifile): Add die_count parameter. (main): Pass multifile_die_count to optimize_multifile and read_multifile. --- dwz.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dwz.c b/dwz.c index 26ac55b..a4073c3 100644 --- a/dwz.c +++ b/dwz.c @@ -12297,7 +12297,7 @@ static unsigned int *strp_tail_off_list; /* Process temporary .debug_* files, see what can be beneficially shared and write a new ET_REL file, containing the shared .debug_* sections. */ static int -optimize_multifile (void) +optimize_multifile (unsigned int *die_count) { DSO dsobuf, *dso; int fd = -1; @@ -12478,7 +12478,7 @@ optimize_multifile (void) strp_tail_off_list = finalize_strp (true); write_abbrev (); - write_info (NULL); + write_info (die_count); write_gdb_index (); if (write_multifile_line ()) goto fail; @@ -12682,7 +12682,7 @@ optimize_multifile (void) by optimize_multifile into data structures for fi_multifile phase. */ static DSO * -read_multifile (int fd) +read_multifile (int fd, unsigned int die_count) { DSO *dso, *volatile ret; unsigned int i; @@ -12715,7 +12715,7 @@ read_multifile (int fd) obstack_init (&ob); obstack_init (&ob2); - if (read_dwarf (dso, false, NULL)) + if (read_dwarf (dso, false, &die_count)) goto fail; if (debug_sections[DEBUG_STR].size) @@ -13108,11 +13108,12 @@ main (int argc, char *argv[]) } if (multifile) { - int multi_fd = optimize_multifile (); + unsigned int multifile_die_count = 0; + int multi_fd = optimize_multifile (&multifile_die_count); DSO *dso; if (multi_fd == -1) return 1; - dso = read_multifile (multi_fd); + dso = read_multifile (multi_fd, multifile_die_count); if (dso == NULL) ret = 1; else