From patchwork Mon Feb 12 21:31:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 85636 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B94783858404 for ; Mon, 12 Feb 2024 21:31:53 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C68C23858C52 for ; Mon, 12 Feb 2024 21:31:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C68C23858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C68C23858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707773509; cv=none; b=g6fXNAFtnaMshfS1oNmtnmDo7FgLHzu11j//gPKIV4c1AzP99JJibLyUuuQkDy6WtgfWc4q+1ZGX8V4B6ttauGmnkWKKI7vCUSWtHZ6gbwIPh0UpLip1prXgcE1anLPOYCEJyyZvP8Faz3tyh64biCcb2ees4dbquxesFDeN6Qc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707773509; c=relaxed/simple; bh=P+joXBwpDaKLKPWviBXoZZp2QX9GUgogM29D8wRINus=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=I1E3Z/cZnaLsXqNgIa7tvnlP9G2TBbScH5fxk+zH8tEpdzKB1vKf052gu3/j0gOf6XpPJ70Et9/w52ZTt9nJwJj5p7sWNBZAbeb6mJTnxCq/G+Ql/DTqqUUnACtEmsYrsCpC/WMguu6yi7r2fgNf9BGRQ/OXoOSEMb7LIfFAz6g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707773506; 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=wML3EP0ChyIDc1tm3AOl7/iKibjYL2B5imx6/KD/ZOg=; b=BOyJ7GiWM+KG2LEo+gIa6d8EU3Jxc6v5B8QxNFU1Lj/RxNEnyiyGejH0CkTG8WRsAOhXpp 0lKgkvNwKm7jOH8y/mKcFAdJKXKKjphFRllxv/s+1yCEB589qWUQtKA86cCrBpdu15kk0j yA70sd4TzbmP/kSx+Fx4oBSLA4etOmk= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-375-nYOzIzMENbilGEMJVIRFMQ-1; Mon, 12 Feb 2024 16:31:45 -0500 X-MC-Unique: nYOzIzMENbilGEMJVIRFMQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-68c4f4bdcaaso73141926d6.1 for ; Mon, 12 Feb 2024 13:31:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707773504; x=1708378304; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wML3EP0ChyIDc1tm3AOl7/iKibjYL2B5imx6/KD/ZOg=; b=mcfueArwI/E3QImau0uGIVzYZYIuM/r/9D64CmIN7MrwQzI7PmARe7swrCpcLIAO3y jcZ/1WRsoZlO5aw5FoCG4wEceLfFmkjpKvk2b2+v0Osf5nPPX6LxEw6yW/HSBsQheBVN 0w58H76n/tUhSqc2Rr48HossVpCay8NxmzoLQKLNKsQ6XVEhS4vRe1BoFVXukWwpqyMz bZLkdDJe0Hw2/BuTCuzD9UA7/GZnGZ2e4SG9P7xWpD6F/5qCA9WDJHyvMJUwfSqBe57Q O/Y3B5gxjaAUdSpJj4DdI35q0dpF/riSZAM+04iiuINEcIdUrO1RTZ1b2Ky2FmwUHe+4 ZIZg== X-Gm-Message-State: AOJu0YybM+doUJQkTD7YTdxMRXxLv7OxMsBWgFb1qOd+qOYBP6k9n2NX pBx99HaB41hnyO/WiGBViX1rGwC0bcK/6sDxa5nflubynqv64SlKQWpGqDKVZQSDRUb/nfog2Kb zwhomUYeVk4k8wDdkSHmhldPmJ6wKK6959qK7E7K+ikorWjIBxZNmxqsCUA== X-Received: by 2002:a0c:dd08:0:b0:68c:48fd:4441 with SMTP id u8-20020a0cdd08000000b0068c48fd4441mr8064762qvk.64.1707773504268; Mon, 12 Feb 2024 13:31:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiuaGaS14r/KNySDxWfN/qUCfHzU/mQtyaFQNqQTta3iJxK2aqVsrXeyDkf9oP81txYrXrOA== X-Received: by 2002:a0c:dd08:0:b0:68c:48fd:4441 with SMTP id u8-20020a0cdd08000000b0068c48fd4441mr8064748qvk.64.1707773504007; Mon, 12 Feb 2024 13:31:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVwBTh7VEFCI5yan3QyOyu/cVYaRBIwy9Ul3ilEx8giAa3sEpLOJU5o3E4plXe7AR4fORKby8MTei8h9Qh0Emds Received: from localhost (88-120-130-27.subs.proxad.net. [88.120.130.27]) by smtp.gmail.com with ESMTPSA id lq1-20020a0562145b8100b0068c8aea8d9fsm575177qvb.13.2024.02.12.13.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 13:31:43 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 20411B4FCA; Mon, 12 Feb 2024 22:31:42 +0100 (CET) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH, applying to mainline] ir: Cache internal name for several types Organization: Red Hat / France X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Mon, 12 Feb 2024 22:31:42 +0100 Message-ID: <87mss5xtc1.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 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, T_SCC_BODY_TEXT_LINE 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: libabigail@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Hello, Profiling showed that computing function type names while sorting types prior to type hashing was taking a lot of time. Caching function, reference, pointers and qualified type names reduces that time a lot. This is what this patch does, in prevision for the up coming type hashing patch. * src/abg-ir.cc ({qualified_type_def, pointer_type_def, reference_type_def}::get_qualified_name): Cache the internal qualified type name for non-canonicalized types. (function_type::get_cached_name): Cache the internal function type name. Signed-off-by: Dodji Seketeli Applying to the master branch. --- src/abg-ir.cc | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index f4d9174f..9f053aef 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -17241,7 +17241,8 @@ qualified_type_def::get_qualified_name(bool internal) const // We are asked to return a temporary *internal* name. // Lets compute it and return a reference to where it's // stored. - priv_->temporary_internal_name_ = + if (priv_->temporary_internal_name_.empty()) + priv_->temporary_internal_name_ = env.intern(build_name(true, /*internal=*/true)); return priv_->temporary_internal_name_; } @@ -17734,7 +17735,8 @@ pointer_type_def::get_qualified_name(bool internal) const // cache where we store its name at each invocation of this // function. if (pointed_to_type) - priv_->temp_internal_qualified_name_ = + if (priv_->temp_internal_qualified_name_.empty()) + priv_->temp_internal_qualified_name_ = pointer_declaration_name(this, /*variable_name=*/"", /*qualified_name=*/ @@ -18141,14 +18143,15 @@ reference_type_def::get_qualified_name(bool internal) const // cache where we store its name at each invocation of this // function. if (pointed_to_type) - priv_->temp_internal_qualified_name_ = - get_name_of_reference_to_type(*pointed_to_type, - is_lvalue(), - /*qualified_name=*/ - is_typedef(pointed_to_type) - ? false - : true, - /*internal=*/true); + if (priv_->temp_internal_qualified_name_.empty()) + priv_->temp_internal_qualified_name_ = + get_name_of_reference_to_type(*pointed_to_type, + is_lvalue(), + /*qualified_name=*/ + is_typedef(pointed_to_type) + ? false + : true, + /*internal=*/true); return priv_->temp_internal_qualified_name_; } } @@ -21550,9 +21553,9 @@ function_type::get_cached_name(bool internal) const } else { - priv_->temp_internal_cached_name_ = - get_function_type_name(this, - /*internal=*/true); + if (priv_->temp_internal_cached_name_.empty()) + priv_->temp_internal_cached_name_ = + get_function_type_name(this, /*internal=*/true); return priv_->temp_internal_cached_name_; } }