Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1o0AxV-0003Du-Jj for mharc-grub-devel@gnu.org; Sat, 11 Jun 2022 19:56:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0AxT-0003DG-HG for grub-devel@gnu.org; Sat, 11 Jun 2022 19:55:59 -0400 Received: from sonata.ens-lyon.org ([140.77.166.138]:38420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0AxD-0001BH-2D for grub-devel@gnu.org; Sat, 11 Jun 2022 19:55:58 -0400 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 0BB502016F; Sun, 12 Jun 2022 01:55:40 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NaF6Eavw7IPU; Sun, 12 Jun 2022 01:55:39 +0200 (CEST) Received: from begin (anantes-655-1-33-15.w83-195.abo.wanadoo.fr [83.195.225.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 915BC20163; Sun, 12 Jun 2022 01:55:39 +0200 (CEST) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1o0Ax8-004BFw-Vu; Sun, 12 Jun 2022 01:55:38 +0200 Date: Sun, 12 Jun 2022 01:55:38 +0200 From: Samuel Thibault To: Mathieu Desnoyers Cc: grub-devel@gnu.org, Daniel Kiper Subject: Re: [PATCH v5 3/5] grub-mkconfig hurd: Fix quadratic algorithm for sorting menu items Message-ID: <20220611235538.cuhnfipf6radhbfv@begin> References: <20220609185024.447922-1-mathieu.desnoyers@efficios.com> <20220609185024.447922-4-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220609185024.447922-4-mathieu.desnoyers@efficios.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) Received-SPF: pass client-ip=140.77.166.138; envelope-from=SRS0=G8uy=WS=ens-lyon.org=samuel.thibault@bounce.ens-lyon.org; helo=sonata.ens-lyon.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=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: Sat, 11 Jun 2022 23:55:59 -0000 Hello, 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. > > This fix is ported from the 10_linux script, which has a similar > quadratic code pattern. > > [ Note: this is untested. I would be grateful if anyone with a Hurd > environment could test it before it is merged. ] > > Signed-off-by: Mathieu Desnoyers > Cc: Samuel Thibault Tested-by: Samuel Thibault > --- > Changes since v4: > - Combine sed -e '...' -e '...' into sed -e '...; ...' > --- > util/grub.d/10_hurd.in | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > 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= > # 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="" > -is_top_level=true > > -while [ "x$kernels" != "x" ] ; do > - kernel=`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=$(echo ${kernels} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') > > +is_top_level=true > + > +for kernel in ${reverse_sorted_kernels}; do > # The GRUB_DISABLE_SUBMENU option used to be different than others since 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 option to 'y', > @@ -221,8 +227,6 @@ while [ "x$kernels" != "x" ] ; do > > hurd_entry "$kernel" advanced > hurd_entry "$kernel" recovery > - > - kernels=`echo $kernels | tr ' ' '\n' | fgrep -vx "$kernel" | tr '\n' ' '` > done > > # If at least one kernel was found, then we need to > -- > 2.30.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.