From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7165C3858D28 for ; Wed, 18 Jan 2023 11:32:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7165C3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674041537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=AYdal+DxJugbDK8HYWJSzbogq/cKXzTGKeaqbSgrAOg=; b=VOKhyGTLOJ7Vj/vGHmBpb7mewZU5Ud70M04UnhADLMvtYgoprir0y47Hu+T6KPJN6YSXup 6rp3hwyYUjCHct6lz4oFWctt72FyVIM79h/xR4/cvxTcs2aAuYqEnEreYdLfB8U0fbA5BF giYH9EPyAf04MbIqQZ5beqNe78Jzy4k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-526-m1PNplYfPLqAJAqu3Wosdg-1; Wed, 18 Jan 2023 06:32:15 -0500 X-MC-Unique: m1PNplYfPLqAJAqu3Wosdg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93BDB8A011B for ; Wed, 18 Jan 2023 11:32:15 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.33.36.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 422E6140EBF5 for ; Wed, 18 Jan 2023 11:32:15 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Subject: Commit: Improve the performance of objcopy's note merging algorithm Date: Wed, 18 Jan 2023 11:32:14 +0000 Message-ID: <87y1q013k1.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Guys, I am applying the patch below to speed up objcopy's note-merging algorithm. With this patch applied the time taken to merge the notes in Firefox's libxul.so went down from 10 minutes to 5 minutes, on the machine that I was using for testing. Cheers Nick binutils/ChangeLog 2023-01-18 Nick Clifton PR 29993 * objcopy.c (merge_gnu_build_notes): Remember the last non-deleted note in order to speed up the scan for matching notes. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index b8958bcab57..eb2e54b9602 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -2403,6 +2403,8 @@ merge_gnu_build_notes (bfd * abfd, other note then if they are both of the same type (open or func) then they can be merged and one deleted. If they are of different types then they cannot be merged. */ + objcopy_internal_note * prev_note = NULL; + for (pnote = pnotes; pnote < pnotes_end; pnote ++) { /* Skip already deleted notes. @@ -2424,7 +2426,9 @@ merge_gnu_build_notes (bfd * abfd, objcopy_internal_note * back; /* Rule 2: Check to see if there is an identical previous note. */ - for (iter = 0, back = pnote - 1; back >= pnotes; back --) + for (iter = 0, back = prev_note ? prev_note : pnote - 1; + back >= pnotes; + back --) { if (is_deleted_note (back)) continue; @@ -2486,11 +2490,17 @@ merge_gnu_build_notes (bfd * abfd, break; } } -#if DEBUG_MERGE + if (! is_deleted_note (pnote)) - merge_debug ("Unable to do anything with note at %#08lx\n", - (pnote->note.namedata - (char *) contents) - 12); + { + /* Keep a pointer to this note, so that we can + start the next search for rule 2 matches here. */ + prev_note = pnote; +#if DEBUG_MERGE + merge_debug ("Unable to do anything with note at %#08lx\n", + (pnote->note.namedata - (char *) contents) - 12); #endif + } } /* Resort the notes. */