From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 660BB15800A for ; Mon, 31 Jul 2023 12:44:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 13E74E0CBC; Mon, 31 Jul 2023 12:44:52 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8DB0EE0CB8 for ; Mon, 31 Jul 2023 12:44:51 +0000 (UTC) References: <20230731104120.275384-1-flow@gentoo.org> User-agent: mu4e 1.10.4; emacs 30.0.50 From: Sam James To: gentoo-dev@lists.gentoo.org Cc: rust@gentoo.org, Florian Schmaus Subject: Re: [gentoo-dev] [PATCH] cargo.eclass: use CARGO_CRATE_URIS if already available Date: Mon, 31 Jul 2023 13:44:36 +0100 Organization: Gentoo In-reply-to: Message-ID: <87zg3cb680.fsf@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 3fd85189-5a20-41b8-81b5-b0cd80c0f995 X-Archives-Hash: 67bc2ff83fa4e9c74d1b9693dd1ca08c Micha=C5=82 G=C3=B3rny writes: > On Mon, 2023-07-31 at 12:41 +0200, Florian Schmaus wrote: >> With 59dbfb80f748 ("cargo.eclass: Add variable alternative to >> $(cargo_crate_uris)") the _cargo_set_crate_uris function was >> introduced. This function runs when the elcass is inherited and sets >> CARGO_CRATE_URIS. >>=20 >> Ebuilds that use $(cargo_crate_uris) in SRC_URI will again invoke this >> function, even though CARGO_CRATE_URIS is already set. Avoiding this >> unnecessary computation reduces the ebuild source time of >> app-shells/nushell-0.83.0 from 21 ms to 14 ms. >>=20 >> This is a significant reduction when compared to the variable-setting >> alternative that the commit 59dbfb80f748 ("cargo.eclass: Add variable >> alternative to $(cargo_crate_uris)") introduced. Using the >> variable-setting approach would reduce the ebuild source time only by a >> little bit more than one millisecond. >>=20 >> Using >>=20 >> pk pkg source --bench 10s '=3Dapp-shells/nushell-0.83.0' >>=20 >> as benchmark, yields >>=20 >> > | Cached CARGO_CRATE_URIS | Non-Cached CARGO= _CRATE_URIS | >> > ---------------------------+-------------------------+----------------= -------------| >> > $(cargo_crate_uris) | mean: 14.189ms | mean: 21.445ms = | >> > variable-setting approach | mean: 12.822ms | mean: 12.852ms = | >>=20 >> full benchmark output >>=20 >> > | Cached CARGO_CRATE_URIS (this commit) = | Non-Cached CARGO_CRATE_URIS = | >> > ---------------------------+------------------------------------------= ------------------------+--------------------------------------------------= ----------------| >> > $(cargo_crate_uris) | mean: 14.189ms, min: 13.646ms, max: 15.103= ms, =CF=83 =3D 149=C2=B5s, N =3D 705 | mean: 21.445ms, min: 20.79ms, max: = 22.832ms, =CF=83 =3D 228=C2=B5s, N =3D 467 | >> > variable-setting approach | mean: 12.822ms, min: 12.41ms, max: 13.909= ms, =CF=83 =3D 165=C2=B5s, N =3D 780 | mean: 12.852ms, min: 12.367ms, max: = 15.437ms, =CF=83 =3D 227=C2=B5s, N =3D 779 | >>=20 >> Signed-off-by: Florian Schmaus >> --- >> eclass/cargo.eclass | 8 ++++++++ >> 1 file changed, 8 insertions(+) >>=20 >> diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass >> index 70b6008d9cd8..5d6911801097 100644 >> --- a/eclass/cargo.eclass >> +++ b/eclass/cargo.eclass >> @@ -240,6 +240,14 @@ _cargo_set_crate_uris "${CRATES}" >> # Constructs a list of crates from its arguments. >> # If no arguments are provided, it uses the CRATES variable. >> cargo_crate_uris() { >> + # Use already existing value for CARGO_CRATE_URIS, computed by >> + # _cargo_set_crate_uris, when this function is invoked without >> + # arguments. >> + if [[ $# -eq 0 && -n "${CARGO_CRATE_URIS}" ]]; then >> + echo "${CARGO_CRATE_URIS}" >> + return >> + fi >> + >> local crates=3D${*-${CRATES}} >> if [[ -z ${crates} ]]; then >> eerror "CRATES variable is not defined and nothing passed as argument" > > This incorrectly assumes that the value of CRATES did not change which > isn't guaranteed anywhere. Ah, thanks! Now I remember - we discussed it before and rejected it for this reason.