From patchwork Wed Jan 18 11:32:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 45183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2284052wrn; Wed, 18 Jan 2023 03:32:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXutBktrZI+jh8v0LkEYPUVek3+i5myKHKRn5C3Ma43T+k+OT8FF38C0r+lKHvGmih/VuTzt X-Received: by 2002:a17:906:bc5a:b0:871:ed54:60a3 with SMTP id s26-20020a170906bc5a00b00871ed5460a3mr6833750ejv.23.1674041546184; Wed, 18 Jan 2023 03:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674041546; cv=none; d=google.com; s=arc-20160816; b=knxU1UdDcaxCTfsApDG/nNC1AbZgLnhMEL/Q3ggv8coi5rmeOsB3BQCjz6NK6eardg qaYh6jSMZJuw397YtuCzVi3Jt6qIDUBM3COwH4+Uu31EuO1mZkxYgw8R3pzAN02wYMLj 68ii/WZC1Q4VAAmU0ZIKKOGu4npmbWzetrp6LUfvwwPc1CuRyrhW7YjvdEL/SwRLvvbG toN249oZ371sL6vE82tTp1Bfxql9sh1TiM5jqtkvEL6nn+qM8yc/yDhjvsW3LJveTePQ UTkBml6u6lWyzwNB3Vvw7l+4waSSQ+H+Coq+oD1p84w/u+gHjRPRjQhu2E2tMaJJSUi5 YAqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=AYdal+DxJugbDK8HYWJSzbogq/cKXzTGKeaqbSgrAOg=; b=a60oTipTbZ7dFBexFiyGNqAAHf2BkHLkgKbxK0VTfGzvmJULprMfZlPdkP3/FrLPmS scEzFG2e74vkjpYitaunE5JblEPivkmXJWUFoyi99fidVbLtNrPnORF//t3O/TgVzFrc hmPcMvtjwVrUhPv6fkeK0O8QB34tlWdYwy0OY6CcOtOjmmL3K9ghFa1xvmrw/axhOTHo pzR+QDqqBgr9cvbg5VlltMFocfTKzT5PRatAUCWxZJPyZAeekWc7LR1tgrF72TVGXV0b 1ZKq71aJsb8bH9mqkrDQDorEshC3x3AcORAOj2S+d7eBLDAylRDyi6SISdCu3wmzhwx2 kw4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CW1j2I8T; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id oz31-20020a1709077d9f00b008773f54e94bsi2435819ejc.553.2023.01.18.03.32.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 03:32:26 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CW1j2I8T; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 24D763858C62 for ; Wed, 18 Jan 2023 11:32:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24D763858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674041545; bh=AYdal+DxJugbDK8HYWJSzbogq/cKXzTGKeaqbSgrAOg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=CW1j2I8TKjxbmEgMRpK5ZMjFo4TwFtH6VoEAiI0CKSgRPqTU+Ondj64uaJBXEWa8T 0ADxL8zExnEVszcY1+JjJK8dgKn4a0dLBStnaGT4qqz0td6uJrpHHfEUjU+0mbLtbw YLbOTKJjozkrJUOYIBzpmLVy6Lo8EpCI2b2iE06A= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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) 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 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Nick Clifton via Binutils From: Nick Clifton Reply-To: Nick Clifton Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755359787861387875?= X-GMAIL-MSGID: =?utf-8?q?1755359787861387875?= 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. */