From unknown Sat Jun 21 03:30:57 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#66138 <66138@debbugs.gnu.org> To: bug#66138 <66138@debbugs.gnu.org> Subject: Status: [PATCH 1/4] etc/committer: Do not recompute changes when there are no definitions. Reply-To: bug#66138 <66138@debbugs.gnu.org> Date: Sat, 21 Jun 2025 10:30:57 +0000 retitle 66138 [PATCH 1/4] etc/committer: Do not recompute changes when ther= e are no definitions. reassign 66138 guix-patches submitter 66138 Ricardo Wurmus severity 66138 normal tag 66138 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 21 10:13:28 2023 Received: (at submit) by debbugs.gnu.org; 21 Sep 2023 14:13:28 +0000 Received: from localhost ([127.0.0.1]:34547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKQm-0006St-FM for submit@debbugs.gnu.org; Thu, 21 Sep 2023 10:13:28 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57040) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKQh-0006Sb-5X for submit@debbugs.gnu.org; Thu, 21 Sep 2023 10:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjKQO-00077Z-LL for guix-patches@gnu.org; Thu, 21 Sep 2023 10:13:01 -0400 Received: from sender4-of-o51.zoho.com ([136.143.188.51]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjKQJ-0002Jo-Pr for guix-patches@gnu.org; Thu, 21 Sep 2023 10:13:00 -0400 Delivered-To: rekado@elephly.net ARC-Seal: i=1; a=rsa-sha256; t=1695305570; cv=none; d=zohomail.com; s=zohoarc; b=cfitnZEUZJvMqBhA5oE7xb8P0aPduxxj5abBvAkTKzmUCCIJF37XOgyvayGwnI3MeAJ3PcKzrT8aJ15+KeolTrwY27jfFnH+voj4Qtp8EbHudbYp9IjYeW8Iw6PZUvUhSr4LMmiKI3IhKPjYpdiRXeoAyP+/Z4o9aqQN6lq4mpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695305570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=gsth8uFPTU29ahGVgl+RULuetXwLlbOExpqxj5Y7MDM=; b=EB7Ye2WB3ZCKk3eAsd1HY8HCh1GKX+KYCmE0Bns+2QmBK2/6vbQZibEZG/2G+LsKdvEPuSSKVf0zEvE3Q15osfNWjVJ5BD+bn8VDsuV0uWz2Gbuhv+mGnNbtdWCcJ1WwEIgcmyGN0sfZOT4ROn8u5m4bNX30eTwUx/Lu0rZEWBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1695305570; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=gsth8uFPTU29ahGVgl+RULuetXwLlbOExpqxj5Y7MDM=; b=ECnfYFaZ88iDEDJ25HenVgrPa19xCoYb5JwoWWJcxvM2HaD8qWd7faqgurkLpAD9 WWEC5SVoGVXYS6qMVf39a8495uvMYBJOwia+UHclF29Mf9hbNusuN6rCRS6dkOedkz/ zata8418t7E+CFqXxPqQ66zoJmtRPJlH8OuMmEs8= Received: from localhost (141.80.245.246 [141.80.245.246]) by mx.zohomail.com with SMTPS id 1695305568374675.7386370858161; Thu, 21 Sep 2023 07:12:48 -0700 (PDT) From: Ricardo Wurmus To: guix-patches@gnu.org Message-ID: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> Subject: [PATCH 1/4] etc/committer: Do not recompute changes when there are no definitions. Date: Thu, 21 Sep 2023 16:12:41 +0200 X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.51; envelope-from=rekado@elephly.net; helo=sender4-of-o51.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * etc/committer.scm.in (main): Reuse previously computed changes if there a= re no changes to the number of definitions. --- etc/committer.scm.in | 75 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/etc/committer.scm.in b/etc/committer.scm.in index e7f1ca8c45..cc3b572710 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -388,41 +388,46 @@ (define (main . args) (unless (eqv? 0 (status:exit-val (close-pipe port))) (error "Cannot commit")))) (usleep %delay)) - definitions)) + definitions) =20 - ;; Changes. - (for-each - (match-lambda - ((new old . hunks) - (for-each (lambda (hunk) - (let ((port (open-pipe* OPEN_WRITE - "git" "apply" - "--cached" - "--unidiff-zero"))) - (hunk->patch hunk port) - (unless (eqv? 0 (status:exit-val (close-pipe port))= ) - (error "Cannot apply"))) - (usleep %delay)) - hunks) - (define copyright-line - (any (lambda (line) (and=3D> (string-prefix? "+;;; Copyright = =C2=A9" line) - (const line))) - (hunk-diff-lines (first hunks)))) - (cond - (copyright-line - (add-copyright-line copyright-line)) - (else - (let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F" "-"))) - (change-commit-message* (hunk-file-name (first hunks)) - old new) - (change-commit-message* (hunk-file-name (first hunks)) - old new - port) - (usleep %delay) - (unless (eqv? 0 (status:exit-val (close-pipe port))) - (error "Cannot commit"))))))) - ;; XXX: we recompute the hunks here because previous - ;; insertions lead to offsets. - (new+old+hunks (diff-info)))))) + ;; Changes. + (for-each + (match-lambda + ((new old . hunks) + (for-each (lambda (hunk) + (let ((port (open-pipe* OPEN_WRITE + "git" "apply" + "--cached" + "--unidiff-zero"))) + (hunk->patch hunk port) + (unless (eqv? 0 (status:exit-val (close-pipe port= ))) + (error "Cannot apply"))) + (usleep %delay)) + hunks) + (define copyright-line + (any (lambda (line) (and=3D> (string-prefix? "+;;; Copyright = =C2=A9" line) + (const line))) + (hunk-diff-lines (first hunks)))) + (cond + (copyright-line + (add-copyright-line copyright-line)) + (else + (let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F" "-"))) + (change-commit-message* (hunk-file-name (first hunks)) + old new) + (change-commit-message* (hunk-file-name (first hunks)) + old new + port) + (usleep %delay) + (unless (eqv? 0 (status:exit-val (close-pipe port))) + (error "Cannot commit"))))))) + (new+old+hunks (match definitions + ('() changes) ;reuse + (_ + ;; XXX: we recompute the hunks here because prev= ious + ;; insertions lead to offsets. + (let-values (((definitions changes) + (partition hunk-type (diff-info)))= ) + changes))))))))) =20 (apply main (cdr (command-line))) base-commit: 4bdb8bd2674c2b630626be43a5cd3c2b65401b52 --=20 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 21 10:46:50 2023 Received: (at 66138) by debbugs.gnu.org; 21 Sep 2023 14:46:50 +0000 Received: from localhost ([127.0.0.1]:34604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKx3-0007Im-U5 for submit@debbugs.gnu.org; Thu, 21 Sep 2023 10:46:50 -0400 Received: from sender3-of-o57.zoho.com ([136.143.184.57]:21794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKwu-0007IS-Nr for 66138@debbugs.gnu.org; Thu, 21 Sep 2023 10:46:43 -0400 Delivered-To: rekado@elephly.net ARC-Seal: i=1; a=rsa-sha256; t=1695307583; cv=none; d=zohomail.com; s=zohoarc; b=ks9fwm3feEGIBgKQTJAyRfW4F3QVBDada5pE3ifMHzaEv/ogeZc1BBogFtEG+mN2iSnXI2YhO6P2bgVzFAtbYvyxSvkGWHNTkqPqzToVh2SNZm2gfV31JBB4PlQLT8cBktRNwmjCVZF/rIfkVZyj+Kwl2R46eGVaqYS3DaBNUlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695307583; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=TR9FuU2Yn9xFe5Z8qpK+yBZleUnqGaJR1yGoBoD1z6A=; b=gTZuYvFd3P84bTiCcsQYyePt3iYDY+LND1BU4fYSjWAc3ODg/xQeH+KkF39TlF+sbYFMmrMpq3NAqVIHkrHwtEgKUdYeqLNIvX0U/UylWaVAVl2AqE9rGwzKQkawY74wNELEsy8akqirJydmQvyuoddN98nz10Vckdk1B/TqPKM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1695307583; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=TR9FuU2Yn9xFe5Z8qpK+yBZleUnqGaJR1yGoBoD1z6A=; b=W5xb8tNlWk1aDZF21QJ+NXP27v86zHdmlqgTQTKydwFXtqIyRDggfRAPUewRljaa KECswKMsYswMUKmeuONtyR+kWYR30nLIUXKNQtISd8iqlwKm69Kl0eoI7FxoarmrBa9 1GVPNVOwkwLI4CFEa2gq2JX2FQL54eks1f0gGw5s= Received: from localhost (141.80.245.246 [141.80.245.246]) by mx.zohomail.com with SMTPS id 1695307582761691.715689423495; Thu, 21 Sep 2023 07:46:22 -0700 (PDT) From: Ricardo Wurmus To: 66138@debbugs.gnu.org Message-ID: <9c0df8930cdc415953a2dce8172edaa8944333fc.1695305549.git.rekado@elephly.net> Subject: [PATCH 2/4] etc/committer: Do not record positions when reading from git files. Date: Thu, 21 Sep 2023 16:46:15 +0200 X-Mailer: git-send-email 2.41.0 In-Reply-To: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> References: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66138 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This gives us a slight performance boost. * etc/committer.scm.in (main): Disable recording of positions. --- etc/committer.scm.in | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/committer.scm.in b/etc/committer.scm.in index cc3b572710..45efb68be2 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -358,6 +358,7 @@ (define (main . args) (_ (apply change-commit-message file-name old new rest))))) =20 + (read-disable 'positions) (match (diff-info) (() (display "Nothing to be done.\n" (current-error-port))) --=20 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 21 10:46:52 2023 Received: (at 66138) by debbugs.gnu.org; 21 Sep 2023 14:46:52 +0000 Received: from localhost ([127.0.0.1]:34606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKx8-0007Iz-CH for submit@debbugs.gnu.org; Thu, 21 Sep 2023 10:46:52 -0400 Received: from sender3-of-o57.zoho.com ([136.143.184.57]:21797) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKx2-0007Ij-8Z for 66138@debbugs.gnu.org; Thu, 21 Sep 2023 10:46:48 -0400 Delivered-To: rekado@elephly.net ARC-Seal: i=1; a=rsa-sha256; t=1695307587; cv=none; d=zohomail.com; s=zohoarc; b=Bzyfw6oTh7gWkRZri0QaAqCuB4PXo0sDu81rlHxfCYqy+A/yk6aw4EiIJ2szwA2X55zKOFZmN4/PknJ34hcm5LBtg1tTpBG+GHd9mb8lWu8MpdZ54nXhsp4L7Y2/1tbk+gz3fenlv5xgDivxlG2Q187u0fnq9B9Yy/sQbMWiWyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695307587; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2sCtuGczjdVKVRe0xueDENm6iOweokxzh4DtmIal2s0=; b=T3zLWmmQJLbZy9OS9aFLKCObu0p8yYyURPGQEAQ7lW2qQWuVBSbs4/YEdiWxbO52Dij2zaCboDkkTV0++C3dZfk3kHfiyfnH4tN1hypg+lpylFYssez+BPAmtKCakuGid0eiTMLgxd6syAu0056ODjlzim9EmUptuQQtRHYSHac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1695307587; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=2sCtuGczjdVKVRe0xueDENm6iOweokxzh4DtmIal2s0=; b=G4DwDjjPK7mEmRWnfBYpKdU/tOJ1D1DgUBmBzONyKr+UqNvMqvXKIm6C96ecGxTy eU05B7Qiv/wZoe4PAkH73zAgvZSfOw9tA5wPWRWLrZWHm0WKEvlUB0dS+/UTNVN3jjH 563Nqp3Sr/jYrNGX/Cu1wENya4YlKGoZ7guMi3PI= Received: from localhost (141.80.245.246 [141.80.245.246]) by mx.zohomail.com with SMTPS id 1695307585901946.7685561359534; Thu, 21 Sep 2023 07:46:25 -0700 (PDT) From: Ricardo Wurmus To: 66138@debbugs.gnu.org Message-ID: Subject: [PATCH 3/4] etc/committer: Avoid reading original files more than once. Date: Thu, 21 Sep 2023 16:46:16 +0200 X-Mailer: git-send-email 2.41.0 In-Reply-To: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> References: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66138 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * etc/committer.scm.in (%original-file-cache): New variable. (read-original-file): New procedure. (read-original-file*): New procedure. (old-sexp): Use it. --- etc/committer.scm.in | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/etc/committer.scm.in b/etc/committer.scm.in index 45efb68be2..eb8865513e 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -196,21 +196,34 @@ (define (lines-to-first-change hunk) (string-ref line 0))) (hunk-diff-lines hunk)))) =20 -(define (old-sexp hunk) - "Using the diff information in HUNK return the unmodified S-expression -corresponding to the top-level definition containing the staged changes." - ;; TODO: We can't seek with a pipe port... +(define %original-file-cache + (make-hash-table)) + +(define (read-original-file file-name) + "Return the contents of FILE-NAME prior to any changes." (let* ((port (open-pipe* OPEN_READ "git" "cat-file" "-p" (string-append - "HEAD:" - (hunk-file-name hunk)))) + "HEAD:" file-name))) (contents (get-string-all port))) (close-pipe port) - (call-with-input-string contents - (lambda (port) - (surrounding-sexp port - (+ (lines-to-first-change hunk) - (hunk-old-line-number hunk))))))) + contents)) + +(define (read-original-file* file-name) + "Caching variant of READ-ORIGINAL-FILE." + (or (hashv-ref %original-file-cache file-name) + (let ((value (read-original-file file-name))) + (hashv-set! %original-file-cache file-name value) + value))) + +(define (old-sexp hunk) + "Using the diff information in HUNK return the unmodified S-expression +corresponding to the top-level definition containing the staged changes." + ;; TODO: We can't seek with a pipe port... + (call-with-input-string (read-original-file* (hunk-file-name hunk)) + (lambda (port) + (surrounding-sexp port + (+ (lines-to-first-change hunk) + (hunk-old-line-number hunk)))))) =20 (define (new-sexp hunk) "Using the diff information in HUNK return the modified S-expression --=20 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 21 10:46:56 2023 Received: (at 66138) by debbugs.gnu.org; 21 Sep 2023 14:46:56 +0000 Received: from localhost ([127.0.0.1]:34609 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKxE-0007JM-6R for submit@debbugs.gnu.org; Thu, 21 Sep 2023 10:46:56 -0400 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKx8-0007Ix-Qi for 66138@debbugs.gnu.org; Thu, 21 Sep 2023 10:46:54 -0400 Delivered-To: rekado@elephly.net ARC-Seal: i=1; a=rsa-sha256; t=1695307591; cv=none; d=zohomail.com; s=zohoarc; b=kUayLwpi8+HdOq5xgLUv0waH/gA/LlhBOPQ0fIFvEehh02YbtfyH9MXRfWkfNDlqJhPRbnND55CaqsrkLHkZIGYgHC/5M5VCpnp5GSHFU+2Qp+arHczpLvMvGQSoh9ayaw52n/tvLbcBD+dWfsSE329s1W8hyHu4RUp2nWuYvnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695307591; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=C9hWs40LFEpYNDLxgjSVTCMJWBUd6tW8XqpJ1zGs0WY=; b=Z/QHi1Xn52T7okjaf8TifJY+DgrZr+vwlirf7aI22fKBHvDKoDPywggrdDHezWewpnOealwKRNWBFm8XpD9y+DnBhSM/OKZkawYCl/oM5GNNSVSFYt56zUOP38nzYwzM5jwgrspoWg+jD4n3p76GlmiO0/BWiPr7+UvN2+JumMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1695307591; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=C9hWs40LFEpYNDLxgjSVTCMJWBUd6tW8XqpJ1zGs0WY=; b=F+orDq/FST1Xj5mrZf9DcI5xE+QiJCnqhE9iHHPu2R8c2t7StR5JSLGy+HUncq7I ilHZFpMgCx8qIIewQyTt/8Vo+BsbuJqhcjpaY53dBOlBVdjCW2Rh4GyYtuD1vxck4kM DUdtKAkif151cQn3xgcg/tIZQawsm5U2EIZ+lnrQ= Received: from localhost (141.80.245.246 [141.80.245.246]) by mx.zohomail.com with SMTPS id 169530758900326.33740265246354; Thu, 21 Sep 2023 07:46:29 -0700 (PDT) From: Ricardo Wurmus To: 66138@debbugs.gnu.org Message-ID: <2bba46036e61fa5899b59372756ac9c5a7403762.1695305549.git.rekado@elephly.net> Subject: [PATCH 4/4] etc/committer: Speed up surrounding-sexp. Date: Thu, 21 Sep 2023 16:46:17 +0200 X-Mailer: git-send-email 2.41.0 In-Reply-To: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> References: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66138 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) The old surrounding-sexp procedure would read all S-expressions from the beginning of the file up to the given line number and then return the last encountered S-expression. This is quite wasteful. Instead we can record a= ll lines that begin with an S-expression and jump straight to the offset close= st to the desired line number to read the S-expression there. * etc/committer.scm.in (lines+offsets-with-opening-parens): New procedure. (surrounding-sexp): Use it. --- etc/committer.scm.in | 46 ++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/etc/committer.scm.in b/etc/committer.scm.in index eb8865513e..0705b29fd9 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -85,21 +85,39 @@ (define (read-excursion port) (seek port start SEEK_SET) result)) =20 -(define (surrounding-sexp port line-no) +(define (lines+offsets-with-opening-parens port) + "Record all line numbers (and their offsets) where an opening parenthesi= s is +found in column 0. The resulting list is in reverse order." + (let loop ((acc '()) + (number 0)) + (let ((line (read-line port))) + (cond + ((eof-object? line) acc) + ((string-prefix? "(" line) + (loop (cons (cons number ;line number + (- (ftell port) + (string-length line) 1)) ;offset + acc) + (1+ number))) + (else (loop acc (1+ number))))))) + +(define (surrounding-sexp port target-line-no) "Return the top-level S-expression surrounding the change at line number -LINE-NO in PORT." - (let loop ((i (1- line-no)) - (last-top-level-sexp #f)) - (if (zero? i) - last-top-level-sexp - (match (peek-char port) - (#\( - (let ((sexp (read-excursion port))) - (read-line port) - (loop (1- i) sexp))) - (_ - (read-line port) - (loop (1- i) last-top-level-sexp)))))) +TARGET-LINE-NO in PORT." + (let* ((line-numbers+offsets + (lines+offsets-with-opening-parens port)) + (closest-offset + (or (and=3D> (list-index (match-lambda + ((line-number . offset) + (< line-number target-line-no))) + line-numbers+offsets) + (lambda (index) + (match (list-ref line-numbers+offsets index) + ((line-number . offset) offset)))) + (error "Could not find surrounding S-expression for line" + target-line-no)))) + (seek port closest-offset SEEK_SET) + (read port))) =20 ;;; Whether the hunk contains a newly added package (definition), a remove= d ;;; package (removal) or something else (#false). --=20 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 24 08:13:07 2023 Received: (at 66138-done) by debbugs.gnu.org; 24 Sep 2023 12:13:07 +0000 Received: from localhost ([127.0.0.1]:41210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qkNz1-0007qq-6c for submit@debbugs.gnu.org; Sun, 24 Sep 2023 08:13:07 -0400 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21128) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qkNyy-0007qf-D0 for 66138-done@debbugs.gnu.org; Sun, 24 Sep 2023 08:13:05 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1695557570; cv=none; d=zohomail.com; s=zohoarc; b=TknxPL7FsRWGGVcHhO3AQYxQFEVVg1oXDc5w1wjHj9DC29vcc5g3u3dYJaATZk3WVZeSbyHG/+OPbXYzejsx/AoeqGZmDGM0rlAW25mP0eGKeDsUbovsyMQbrbTJHXnCwjBO7tSnExhjLqx3PeEGT3NZH53Swc1xon1/6MQ30ak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695557570; h=Content-Type:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=sV8nCP/XQCvRk0XVPFqa3JRwmfSm6I1WSNaT0gXn1xM=; b=nMv04XG5cBSkOYwbXnJ5Tt7bHtA4GWa/blp07UuPpLXTmJHYj1ROkH7lQP5yDwMQefWUHnug+F5Y4GwN2NZiPHOVTNaWSl8SYppfOgCZK4T5DZHcFznZPeHiW2+By01wLvfTbzEBBfL77YN8uLsdW/cCCkISirbnCuTajhtDy7U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1695557570; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:From:To:To:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Message-Id:Reply-To:Cc; bh=sV8nCP/XQCvRk0XVPFqa3JRwmfSm6I1WSNaT0gXn1xM=; b=E/UIZdLylcuUGImEhJRM9T6uueK8sb+MsE8Hd82rjq98Fsy1ilqyaalnzpzzcn9P d0BbaZnXyxGgVXFS7eXDTQtmiWtPPVeH4ZB83BmJ43JcRtZNkR7XVqylc+//HWhSm+s jQLhVO0JNLU3cUh4u5twKkZ1674g6SGXT5chXekM= Received: from localhost (17-122-142-46.pool.kielnet.net [46.142.122.17]) by mx.zohomail.com with SMTPS id 1695557568805815.137423779699; Sun, 24 Sep 2023 05:12:48 -0700 (PDT) References: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> User-agent: mu4e 1.10.7; emacs 29.0.92 From: Ricardo Wurmus To: 66138-done@debbugs.gnu.org Subject: Re: [PATCH 1/4] etc/committer: Do not recompute changes when there are no definitions. Date: Sun, 24 Sep 2023 14:12:28 +0200 In-reply-to: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> Message-ID: <87r0mn6a81.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66138-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I just pushed this series. -- Ricardo From unknown Sat Jun 21 03:30:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 23 Oct 2023 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator