Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1o0keK-00017Z-L1 for mharc-grub-devel@gnu.org; Mon, 13 Jun 2022 10:02:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0keJ-000161-Nc for grub-devel@gnu.org; Mon, 13 Jun 2022 10:02:35 -0400 Received: from mail.efficios.com ([167.114.26.124]:60682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0keE-0002Yz-ET for grub-devel@gnu.org; Mon, 13 Jun 2022 10:02:35 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 9905F3B18EF; Mon, 13 Jun 2022 10:02:28 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id AedZ0Pc3r32u; Mon, 13 Jun 2022 10:02:28 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 114953B18EC; Mon, 13 Jun 2022 10:02:28 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 114953B18EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1655128948; bh=gpPzKmZBcM51C6FFlIEn0GkSOJTc0CnNT2feDLsT8Vo=; h=Date:From:To:Message-ID:MIME-Version; b=UHw3HrKFyHoEQiCWxHpdHQiMZ6bwRXcRDORqgoNSZzu7CZALq+d0dpSEaDh1tbpOK kYQurhdqB8nUmranH0LdceapjS1S0jAYUvwXDFwLKCDI0I/88CG33ct+CETt46zLSP 3Dqz+IVVMKhaIGidUER1N3LHwigR4yx4h6jyFtdHL3Cvn833YCerrhcZFjHvSwUw+b LyzQ4ObswFjI5Ab2c2QqY83tfymgFZfttrVR9ER56uGW8PDEx78srVjUKIVvcJo28N beQ2V5rq+Cr6c1/MwwUOQXUV4BOGfvzClgmMUr09jExoGs6UKCT+GVC3OWo+d/dvyr 7pD4mzeZ+gShg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id k5UL74B578qu; Mon, 13 Jun 2022 10:02:28 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 050503B1277; Mon, 13 Jun 2022 10:02:28 -0400 (EDT) Date: Mon, 13 Jun 2022 10:02:27 -0400 (EDT) From: Mathieu Desnoyers To: samuel thibault Cc: grub-devel , Daniel Kiper Message-ID: <745087496.55926.1655128947976.JavaMail.zimbra@efficios.com> In-Reply-To: <20220611235538.cuhnfipf6radhbfv@begin> References: <20220609185024.447922-1-mathieu.desnoyers@efficios.com> <20220609185024.447922-4-mathieu.desnoyers@efficios.com> <20220611235538.cuhnfipf6radhbfv@begin> Subject: Re: [PATCH v5 3/5] grub-mkconfig hurd: Fix quadratic algorithm for sorting menu items MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_4272 (ZimbraWebClient - FF100 (Linux)/8.8.15_GA_4257) Thread-Topic: grub-mkconfig hurd: Fix quadratic algorithm for sorting menu items Thread-Index: edlZeHoR1DtewSkjBJswEfVJG0PKvg== Received-SPF: pass client-ip=167.114.26.124; envelope-from=compudj@efficios.com; helo=mail.efficios.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2022 14:02:35 -0000 ----- On Jun 11, 2022, at 7:55 PM, samuel thibault samuel.thibault@ens-lyon= .org wrote: > Hello, >=20 > Mathieu Desnoyers, le jeu. 09 juin 2022 14:50:22 -0400, a ecrit: >> The current implementation of the 10_hurd script implements its menu >> items sorting in bash with a quadratic algorithm, calling "sed", "sort", >> "head", and "grep" to compare versions between individual lines, which >> is annoyingly slow for kernel developers who can easily end up with >> 50-100 kernels in their boot partition. >>=20 >> This fix is ported from the 10_linux script, which has a similar >> quadratic code pattern. >>=20 >> [ Note: this is untested. I would be grateful if anyone with a Hurd >> environment could test it before it is merged. ] >>=20 >> Signed-off-by: Mathieu Desnoyers >> Cc: Samuel Thibault >=20 > Tested-by: Samuel Thibault Noted. Adding your Tested-by tag to the message for my next round. Thanks! Mathieu >=20 >> --- >> Changes since v4: >> - Combine sed -e '...' -e '...' into sed -e '...; ...' >> --- >> util/grub.d/10_hurd.in | 14 +++++++++----- >> 1 file changed, 9 insertions(+), 5 deletions(-) >>=20 >> diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in >> index 2fafa4e59..4294bbe4c 100644 >> --- a/util/grub.d/10_hurd.in >> +++ b/util/grub.d/10_hurd.in >> @@ -197,11 +197,17 @@ title_correction_code=3D >> # Extra indentation to add to menu entries in a submenu. We're not in a= submenu >> # yet, so it's empty. In a submenu it will be equal to '\t' (one tab). >> submenu_indentation=3D"" >> -is_top_level=3Dtrue >> =20 >> -while [ "x$kernels" !=3D "x" ] ; do >> - kernel=3D`version_find_latest $kernels` >> +# Perform a reverse version sort on the entire kernels list. >> +# Temporarily replace the '.old' suffix by ' 1' and append ' 2' for all >> +# other files to order the '.old' files after their non-old counterpart >> +# in reverse-sorted order. >> + >> +reverse_sorted_kernels=3D$(echo ${kernels} | tr ' ' '\n' | sed -e 's/\.= old$/ 1/; >> / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') >> =20 >> +is_top_level=3Dtrue >> + >> +for kernel in ${reverse_sorted_kernels}; do >> # The GRUB_DISABLE_SUBMENU option used to be different than others si= nce it was >> # mentioned in the documentation that has to be set to 'y' instead of= 'true' to >> # enable it. This caused a lot of confusion to users that set the opt= ion to 'y', >> @@ -221,8 +227,6 @@ while [ "x$kernels" !=3D "x" ] ; do >> =20 >> hurd_entry "$kernel" advanced >> hurd_entry "$kernel" recovery >> - >> - kernels=3D`echo $kernels | tr ' ' '\n' | fgrep -vx "$kernel" | tr '\n= ' ' '` >> done >> =20 >> # If at least one kernel was found, then we need to >> -- >> 2.30.2 >>=20 >=20 > -- > Samuel > --- > Pour une =C3=A9valuation ind=C3=A9pendante, transparente et rigoureuse ! > Je soutiens la Commission d'=C3=89valuation de l'Inria. --=20 Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com