From unknown Tue Aug 19 09:59: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#28043 <28043@debbugs.gnu.org> To: bug#28043 <28043@debbugs.gnu.org> Subject: Status: [PATCH] Optimize skkdic conversion Reply-To: bug#28043 <28043@debbugs.gnu.org> Date: Tue, 19 Aug 2025 16:59:57 +0000 retitle 28043 [PATCH] Optimize skkdic conversion reassign 28043 emacs submitter 28043 npostavs@users.sourceforge.net severity 28043 wishlist tag 28043 patch fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 10 23:23:58 2017 Received: (at submit) by debbugs.gnu.org; 11 Aug 2017 03:23:58 +0000 Received: from localhost ([127.0.0.1]:54973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg0YH-0006us-NK for submit@debbugs.gnu.org; Thu, 10 Aug 2017 23:23:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56033) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg0YG-0006ug-6S for submit@debbugs.gnu.org; Thu, 10 Aug 2017 23:23:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dg0Y8-0003Qz-RF for submit@debbugs.gnu.org; Thu, 10 Aug 2017 23:23:51 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dg0Y8-0003Qp-N1 for submit@debbugs.gnu.org; Thu, 10 Aug 2017 23:23:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg0Y5-0008Tw-Q1 for bug-gnu-emacs@gnu.org; Thu, 10 Aug 2017 23:23:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dg0Y1-0003Iy-Lw for bug-gnu-emacs@gnu.org; Thu, 10 Aug 2017 23:23:45 -0400 Received: from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f]:36954) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dg0Y1-0003Ho-Aj for bug-gnu-emacs@gnu.org; Thu, 10 Aug 2017 23:23:41 -0400 Received: by mail-io0-x22f.google.com with SMTP id c74so16065721iod.4 for ; Thu, 10 Aug 2017 20:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:mime-version; bh=A17ws5toREHG+CYtCJ/GimWpZnmTzDcoSiAX7Odp5Lw=; b=ttGKAXGLNimTtFSOWfVj9+5K0fpyVzARbH5ZJ3iKsGUKkiKd4haKgV09YvtIQidUBM HQcBu/XQWVuCnYS8Gqu7xuXmpuHwynv34bbmqNCibk0Bg785A2WTC4aZCJRGFIy8e0HY ENW8xdCn4vjv5t0QEfAKVE5TeZtlbvAzojNZQXwED/idghzs7yEPPmsx81dZ9tsuxghi dZL9UGHlyP0VFdVbe3v09nxMDuj9gGD9DTB48CTHH+KK/ISW8QNiSNvUs6VKX76WRc9F uZ24O9+U7h5cZCUqDnH34dRgYSDTQq0qBNblCbOwozPLnWmcPhdM8uIbPIgR/Mh8sbJY hx3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version; bh=A17ws5toREHG+CYtCJ/GimWpZnmTzDcoSiAX7Odp5Lw=; b=pemG/oNLkq4Z9EwGuxP7UyGzseLwawqK+mdvaWsLngJvDN0YoQUmWPp32hl/DHZ88D k+P1pIkZFCD3A1B7sKaNnKodK1VdCg92sccianY66n1BnytZBpgvBmVS756EFJl2z4p2 YaQa/8XKytlfRVEi/VorsoY4WzRwxNs05jv2DVJlvbDtz9xGe1RgotT5PHjfMvF8k3Wc fFRtBdZMB/pm59pLmF6t6psaEICljqgiXdb/5VKfvW3fQoDWyOCD/HlTkawtkS28hvJm Gm1oTUUoKQPzzLptdI7jKgev2QfdkmZC+RFW7HHpa55q/QO1Ux31VBOd/Wny5zjNBrut Ps1A== X-Gm-Message-State: AHYfb5g4A7UeZ7APCTrzo10QCKdnBa5c4eAj5p5kuOAjjqRJD+A3u/7B gXUnNLYYJSsmFMZr X-Received: by 10.107.157.9 with SMTP id g9mr12837185ioe.46.1502421820410; Thu, 10 Aug 2017 20:23:40 -0700 (PDT) Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id f70sm2908183ita.1.2017.08.10.20.23.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Aug 2017 20:23:39 -0700 (PDT) From: npostavs@users.sourceforge.net To: bug-gnu-emacs@gnu.org Subject: [PATCH] Optimize skkdic conversion Date: Thu, 10 Aug 2017 23:25:17 -0400 Message-ID: <87r2wi23c2.fsf@users.sourceforge.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: submit 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: -3.8 (---) --=-=-= Content-Type: text/plain Tags: patch Severity: wishlist While waiting for a bootstrap, I thought the skkdic conversion was looking a bit slow. The following patches reduce the time needed to less than a third of the original (2m30 to 45s measured using a non-optimized Emacs). The main speedup comes from optimizing lookup-nest-alist and set-nested-alist for the case where the key is a string. I suspect it might be possible to optimize even more by reorganizing things, but my ignorance of Japanese makes that difficult. Each commit message has the time I measured after applying. I checked that the generated ja-dic.el is identical to what was generated before. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=v1-0001-Use-progress-reporter-functions-in-ja-dic-cnv.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch >From b160b3a499983c998a8858a353e78bab5dfa49ad Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 1 Jul 2017 22:39:16 -0400 Subject: [PATCH v1 1/6] Use progress-reporter functions in ja-dic-cnv Baseline timing:(using non-optimized Emacs) time make -C leim -B ../../leim/../lisp/leim/ja-dic/ja-dic.el real 2m30.720s user 2m29.693s sys 0m0.567s * lisp/international/ja-dic-cnv.el (skkdic-collect-okuri-nasi) (skkdic-convert-okuri-nasi): Use progress-reporter functions instead of calculating ratio of work done inline. --- lisp/international/ja-dic-cnv.el | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-c= nv.el index e80b1b2881..ac097837f4 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -267,10 +267,10 @@ skkdic-okuri-nasi-entries (defvar skkdic-okuri-nasi-entries-count 0) =20 (defun skkdic-collect-okuri-nasi () - (message "Collecting OKURI-NASI entries ...") (save-excursion - (let ((prev-ratio 0) - ratio) + (let ((progress (make-progress-reporter "Collecting OKURI-NASI entries" + (point) (point-max) + nil 10))) (while (re-search-forward "^\\(\\(\\cH\\|=E3=83=BC\\)+\\) \\(/\\cj.*= \\)/$" nil t) (let ((kana (match-string 1)) @@ -280,11 +280,7 @@ skkdic-collect-okuri-nasi (cons (cons kana candidates) skkdic-okuri-nasi-entries) skkdic-okuri-nasi-entries-count (1+ skkdic-okuri-nasi-entries-count)) - (setq ratio (floor (* (point) 100.0) (point-max))) - (if (/=3D (/ prev-ratio 10) (/ ratio 10)) - (progn - (message "collected %2d%% ..." ratio) - (setq prev-ratio ratio))) + (progress-reporter-update progress (point)) (while candidates (let ((entry (lookup-nested-alist (car candidates) skkdic-word-list nil nil t))) @@ -292,26 +288,23 @@ skkdic-collect-okuri-nasi (setcar entry (cons kana (car entry))) (set-nested-alist (car candidates) (list kana) skkdic-word-list))) - (setq candidates (cdr candidates)))))))) + (setq candidates (cdr candidates))))) + (progress-reporter-done progress)))) =20 (defun skkdic-convert-okuri-nasi (skkbuf buf) - (message "Processing OKURI-NASI entries ...") (with-current-buffer buf (insert ";; Setting okuri-nasi entries.\n" "(skkdic-set-okuri-nasi\n") (let ((l (nreverse skkdic-okuri-nasi-entries)) - (count 0) - (prev-ratio 0) - ratio) + (progress (make-progress-reporter "Processing OKURI-NASI entries" + 0 skkdic-okuri-nasi-entries-co= unt + nil 10)) + (count 0)) (while l (let ((kana (car (car l))) (candidates (cdr (car l)))) - (setq ratio (floor (* count 100.0) skkdic-okuri-nasi-entries-count) - count (1+ count)) - (if (/=3D (/ prev-ratio 10) (/ ratio 10)) - (progn - (message "processed %2d%% ..." ratio) - (setq prev-ratio ratio))) + (setq count (1+ count)) + (progress-reporter-update progress count) (if (setq candidates (skkdic-reduced-candidates skkbuf kana candidates)) (progn @@ -320,7 +313,8 @@ skkdic-convert-okuri-nasi (insert " " (car candidates)) (setq candidates (cdr candidates))) (insert "\"\n")))) - (setq l (cdr l)))) + (setq l (cdr l))) + (progress-reporter-done progress)) (insert ")\n\n"))) =20 (defun skkdic-convert (filename &optional dirname) --=20 2.11.1 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0002-Optimize-lookup-nested-alist-for-string-KEYSEQ.patch Content-Description: patch >From 4fa69ec127558ed7b5412958ce1fa24bd1770889 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 2 Jul 2017 09:34:58 -0400 Subject: [PATCH v1 2/6] Optimize lookup-nested-alist for string KEYSEQ time make -C leim -B ../../leim/../lisp/leim/ja-dic/ja-dic.el real 1m23.716s user 1m23.010s sys 0m0.587s * lisp/international/mule-util.el (lookup-nested-alist): Use `assq' instead of `assoc' when KEYSEQ is a string. --- lisp/international/mule-util.el | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index e34b01c306..3ae87eb1dd 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -179,15 +179,23 @@ lookup-nested-alist (setq len (length keyseq))) (let ((i (or start 0))) (if (catch 'lookup-nested-alist-tag - (if (listp keyseq) - (while (< i len) - (if (setq alist (cdr (assoc (nth i keyseq) (cdr alist)))) - (setq i (1+ i)) - (throw 'lookup-nested-alist-tag t)))) - (while (< i len) - (if (setq alist (cdr (assoc (aref keyseq i) (cdr alist)))) - (setq i (1+ i)) - (throw 'lookup-nested-alist-tag t)))) + (cond ((stringp keyseq) ; We can use `assq' for characters. + (while (< i len) + (if (setq alist (cdr (assq (aref keyseq i) (cdr alist)))) + (setq i (1+ i)) + (throw 'lookup-nested-alist-tag t)))) + ((arrayp keyseq) + (while (< i len) + (if (setq alist (cdr (assoc (aref keyseq i) (cdr alist)))) + (setq i (1+ i)) + (throw 'lookup-nested-alist-tag t)))) + ((listp keyseq) + (setq keyseq (nthcdr i keyseq)) + (while (< i len) + (if (setq alist (cdr (assoc (pop keyseq) (cdr alist)))) + (setq i (1+ i)) + (throw 'lookup-nested-alist-tag t)))) + (t (signal 'wrong-type-argument (list keyseq))))) ;; KEYSEQ is too long. (if nil-for-too-long nil i) alist))) -- 2.11.1 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0003-Optimize-set-nested-alist-for-string-KEYSEQ.patch Content-Description: patch >From 524246088450c1ced3314890397c2700fb49124f Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Mon, 3 Jul 2017 13:01:46 -0400 Subject: [PATCH v1 3/6] Optimize set-nested-alist for string KEYSEQ time make -C leim -B ../../leim/../lisp/leim/ja-dic/ja-dic.el real 1m7.218s user 1m6.470s sys 0m0.627s * lisp/international/mule-util.el (set-nested-alist): Use `assq' when KEYSEQ is string. --- lisp/international/mule-util.el | 51 ++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 3ae87eb1dd..257f8854c3 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -143,20 +143,43 @@ set-nested-alist See the documentation of `nested-alist-p' for more detail." (or (nested-alist-p alist) (error "Invalid argument %s" alist)) - (let ((islist (listp keyseq)) - (len (or len (length keyseq))) - (i 0) - key-elt slot) - (while (< i len) - (if (null (nested-alist-p alist)) - (error "Keyseq %s is too long for this nested alist" keyseq)) - (setq key-elt (if islist (nth i keyseq) (aref keyseq i))) - (setq slot (assoc key-elt (cdr alist))) - (unless slot - (setq slot (cons key-elt (list t))) - (setcdr alist (cons slot (cdr alist)))) - (setq alist (cdr slot)) - (setq i (1+ i))) + (let ((len (or len (length keyseq))) + (i 0)) + (cond + ((stringp keyseq) ; We can use `assq' for characters. + (while (< i len) + (if (null (nested-alist-p alist)) + (error "Keyseq %s is too long for this nested alist" keyseq)) + (let* ((key-elt (aref keyseq i)) + (slot (assq key-elt (cdr alist)))) + (unless slot + (setq slot (list key-elt t)) + (push slot (cdr alist))) + (setq alist (cdr slot))) + (setq i (1+ i)))) + ((arrayp keyseq) + (while (< i len) + (if (null (nested-alist-p alist)) + (error "Keyseq %s is too long for this nested alist" keyseq)) + (let* ((key-elt (aref keyseq i)) + (slot (assoc key-elt (cdr alist)))) + (unless slot + (setq slot (list key-elt t)) + (push slot (cdr alist))) + (setq alist (cdr slot))) + (setq i (1+ i)))) + ((listp keyseq) + (while (< i len) + (if (null (nested-alist-p alist)) + (error "Keyseq %s is too long for this nested alist" keyseq)) + (let* ((key-elt (pop keyseq)) + (slot (assoc key-elt (cdr alist)))) + (unless slot + (setq slot (list key-elt t)) + (push slot (cdr alist))) + (setq alist (cdr slot))) + (setq i (1+ i)))) + (t (signal 'wrong-type-argument (list keyseq)))) (setcar alist entry) (if branches (setcdr (last alist) branches)))) -- 2.11.1 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0004-Optimize-skkdic-by-avoiding-regexp-matching.patch Content-Description: patch >From 14eb38e18b83a67114f31de99d1bdcd8811bbd37 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 2 Jul 2017 02:00:02 -0400 Subject: [PATCH v1 4/6] Optimize skkdic by avoiding regexp matching time make -C leim -B ../../leim/../lisp/leim/ja-dic/ja-dic.el real 0m57.091s user 0m56.370s sys 0m0.607s * lisp/international/ja-dic-cnv.el (skkdic-reduced-candidates): Call `char-category-set' on the first character of the string directly, instead of using a regexp for the character category. (skkdic--japanese-category-set): New constant. (skkdic-collect-okuri-nasi): Just set `skkdic-okuri-nasi-entries-count' at once at the end rather than updating it throughout the loop. --- lisp/international/ja-dic-cnv.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el index ac097837f4..8878bbd358 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -251,12 +251,16 @@ skkdic-breakup-string ;; Return list of candidates which excludes some from CANDIDATES. ;; Excluded candidates can be derived from another entry. +(defconst skkdic--japanese-category-set (make-category-set "j")) + (defun skkdic-reduced-candidates (skkbuf kana candidates) (let (elt l) (while candidates (setq elt (car candidates)) (if (or (= (length elt) 1) - (and (string-match "^\\cj" elt) + (and (bool-vector-subsetp + skkdic--japanese-category-set + (char-category-set (aref elt 0))) (not (skkdic-breakup-string skkbuf kana elt 0 (length elt) 'first)))) (setq l (cons elt l))) @@ -277,9 +281,7 @@ skkdic-collect-okuri-nasi (candidates (skkdic-get-candidate-list (match-beginning 3) (match-end 3)))) (setq skkdic-okuri-nasi-entries - (cons (cons kana candidates) skkdic-okuri-nasi-entries) - skkdic-okuri-nasi-entries-count - (1+ skkdic-okuri-nasi-entries-count)) + (cons (cons kana candidates) skkdic-okuri-nasi-entries)) (progress-reporter-update progress (point)) (while candidates (let ((entry (lookup-nested-alist (car candidates) @@ -289,6 +291,7 @@ skkdic-collect-okuri-nasi (set-nested-alist (car candidates) (list kana) skkdic-word-list))) (setq candidates (cdr candidates))))) + (setq skkdic-okuri-nasi-entries-count (length skkdic-okuri-nasi-entries)) (progress-reporter-done progress)))) (defun skkdic-convert-okuri-nasi (skkbuf buf) -- 2.11.1 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=v1-0005-Optimize-skkdic-don-t-extract-text-properties.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch >From fec9671820e344cdbb8c06aeb889c0f2df67f87c Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 2 Jul 2017 02:10:23 -0400 Subject: [PATCH v1 5/6] Optimize skkdic: don't extract text properties time make -C leim -B ../../leim/../lisp/leim/ja-dic/ja-dic.el real 0m47.962s user 0m47.487s sys 0m0.390s * lisp/international/ja-dic-cnv.el (skkdic-convert-postfix) (skkdic-convert-prefix, skkdic-get-candidate-list) (skkdic-collect-okuri-nasi, skkdic-extract-conversion-data): Use `match-string-no-properties' instead of `match-string'. --- lisp/international/ja-dic-cnv.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-c= nv.el index 8878bbd358..63eede093d 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -125,10 +125,10 @@ skkdic-convert-postfix =20 ;; Search postfix entries. (while (re-search-forward "^[#<>?]\\(\\(\\cH\\|=E3=83=BC\\)+\\) " nil t) - (let ((kana (match-string 1)) + (let ((kana (match-string-no-properties 1)) str candidates) (while (looking-at "/[#0-9 ]*\\([^/\n]*\\)/") - (setq str (match-string 1)) + (setq str (match-string-no-properties 1)) (if (not (member str candidates)) (setq candidates (cons str candidates))) (goto-char (match-end 1))) @@ -158,10 +158,10 @@ skkdic-convert-prefix "(skkdic-set-prefix\n")) (save-excursion (while (re-search-forward "^\\(\\(\\cH\\|=E3=83=BC\\)+\\)[<>?] " nil t) - (let ((kana (match-string 1)) + (let ((kana (match-string-no-properties 1)) str candidates) (while (looking-at "/\\([^/\n]+\\)/") - (setq str (match-string 1)) + (setq str (match-string-no-properties 1)) (if (not (member str candidates)) (setq candidates (cons str candidates))) (goto-char (match-end 1))) @@ -180,8 +180,8 @@ skkdic-get-candidate-list (let (candidates) (goto-char from) (while (re-search-forward "/[^/ \n]+" to t) - (setq candidates (cons (buffer-substring (1+ (match-beginning 0)) - (match-end 0)) + (setq candidates (cons (buffer-substring-no-properties + (1+ (match-beginning 0)) (match-end 0)) candidates))) candidates)) =20 @@ -277,7 +277,7 @@ skkdic-collect-okuri-nasi nil 10))) (while (re-search-forward "^\\(\\(\\cH\\|=E3=83=BC\\)+\\) \\(/\\cj.*= \\)/$" nil t) - (let ((kana (match-string 1)) + (let ((kana (match-string-no-properties 1)) (candidates (skkdic-get-candidate-list (match-beginning 3) (match-end 3)))) (setq skkdic-okuri-nasi-entries @@ -464,7 +464,7 @@ skkdic-extract-conversion-data (i (match-end 0)) candidates) (while (string-match "[^ ]+" entry i) - (setq candidates (cons (match-string 0 entry) candidates)) + (setq candidates (cons (match-string-no-properties 0 entry) candidat= es)) (setq i (match-end 0))) (cons (skkdic-get-kana-compact-codes kana) candidates))) =20 --=20 2.11.1 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0006-lisp-international-ja-dic-cnv.el-skkdic-convert-o.patch Content-Description: patch >From 99a545062367a2f80d69482df0bb266b358ffa54 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 2 Jul 2017 10:04:02 -0400 Subject: [PATCH v1 6/6] * lisp/international/ja-dic-cnv.el (skkdic-convert-okuri-nasi): Cleanup. time make -C leim -B ../../leim/../lisp/leim/ja-dic/ja-dic.el real 0m46.145s user 0m45.607s sys 0m0.460s --- lisp/international/ja-dic-cnv.el | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el index 63eede093d..6d2753bbf5 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -298,25 +298,19 @@ skkdic-convert-okuri-nasi (with-current-buffer buf (insert ";; Setting okuri-nasi entries.\n" "(skkdic-set-okuri-nasi\n") - (let ((l (nreverse skkdic-okuri-nasi-entries)) - (progress (make-progress-reporter "Processing OKURI-NASI entries" + (let ((progress (make-progress-reporter "Processing OKURI-NASI entries" 0 skkdic-okuri-nasi-entries-count nil 10)) (count 0)) - (while l - (let ((kana (car (car l))) - (candidates (cdr (car l)))) - (setq count (1+ count)) - (progress-reporter-update progress count) - (if (setq candidates - (skkdic-reduced-candidates skkbuf kana candidates)) - (progn - (insert "\"" kana) - (while candidates - (insert " " (car candidates)) - (setq candidates (cdr candidates))) - (insert "\"\n")))) - (setq l (cdr l))) + (pcase-dolist (`(,kana . ,candidates) + (nreverse skkdic-okuri-nasi-entries)) + (setq count (1+ count)) + (progress-reporter-update progress count) + (when (setq candidates + (skkdic-reduced-candidates skkbuf kana candidates)) + (insert "\"" kana " " + (mapconcat #'identity candidates " ") + "\"\n"))) (progress-reporter-done progress)) (insert ")\n\n"))) -- 2.11.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 11 02:39:36 2017 Received: (at 28043) by debbugs.gnu.org; 11 Aug 2017 06:39:36 +0000 Received: from localhost ([127.0.0.1]:55053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg3bb-0003WZ-Qw for submit@debbugs.gnu.org; Fri, 11 Aug 2017 02:39:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55119) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg3bW-0003WH-VJ for 28043@debbugs.gnu.org; Fri, 11 Aug 2017 02:39:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dg3bQ-0008PM-LV for 28043@debbugs.gnu.org; Fri, 11 Aug 2017 02:39:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg3bI-0008MI-WD; Fri, 11 Aug 2017 02:39:17 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4144 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dg3bI-0004CR-Ej; Fri, 11 Aug 2017 02:39:16 -0400 Date: Fri, 11 Aug 2017 09:39:05 +0300 Message-Id: <831soisj5i.fsf@gnu.org> From: Eli Zaretskii To: npostavs@users.sourceforge.net, Kenichi Handa In-reply-to: <87r2wi23c2.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) Subject: Re: bug#28043: [PATCH] Optimize skkdic conversion References: <87r2wi23c2.fsf@users.sourceforge.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28043 Cc: 28043@debbugs.gnu.org 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: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: npostavs@users.sourceforge.net > Date: Thu, 10 Aug 2017 23:25:17 -0400 > > While waiting for a bootstrap, I thought the skkdic conversion was > looking a bit slow. The following patches reduce the time needed to > less than a third of the original (2m30 to 45s measured using a > non-optimized Emacs). The main speedup comes from optimizing > lookup-nest-alist and set-nested-alist for the case where the key is a > string. I suspect it might be possible to optimize even more by > reorganizing things, but my ignorance of Japanese makes that difficult. > > Each commit message has the time I measured after applying. I checked > that the generated ja-dic.el is identical to what was generated before. Thanks. CC'ing Handa-san, who could perhaps suggest more optimizations. I guess you've verified that the results are identical after these optimizations? If so, I see no reason not to push in a few days. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 20:53:19 2017 Received: (at 28043) by debbugs.gnu.org; 22 Aug 2017 00:53:19 +0000 Received: from localhost ([127.0.0.1]:48377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djxRX-0007wp-L3 for submit@debbugs.gnu.org; Mon, 21 Aug 2017 20:53:19 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34629) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djxRW-0007wa-4J; Mon, 21 Aug 2017 20:53:18 -0400 Received: by mail-it0-f67.google.com with SMTP id s132so10817260ita.1; Mon, 21 Aug 2017 17:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Pp3YPuv3dgUsObJ4CuM7w76UaVnxXgeI1BnXqPQaFU0=; b=igmdFzdchnGp6Cv+JK2+YI+e4pH7naZbAvT7zL2dwTYo0XeTR8HQSwaAZecxkmWlF4 Jt5LOprxLG8aBkMZGKLuWsPxY/2hxAIpEQzrfJPBXxU6iyD7mCW51Q55RE07+1RmCb5n SAScPRud185TunHtWllx4KExkOVJ6vfIZExq22FgSKwyDdqaHLOcQjHyP+HBa7HIeMLw bcJ9DWx2JFTePviD7CGg0OwWxHRaDUljtd+XJBMZOi7T9meGSIPIBY3jrSvg/eBrhcQK rq5rfPvea+XlhShGXwyljEWHqLlE7Ir0Y/RqJBmQFV1xGi3okS0Z8DhrESd0VX3JATLa WRKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=Pp3YPuv3dgUsObJ4CuM7w76UaVnxXgeI1BnXqPQaFU0=; b=XPRc8NT7OE+zdz78SZULcUPPQ5SwQq70ae4pdJnRLtVk1+hj8zkXHoqZS4fwuBfshr 8QwQpHKk+zc3IcY1IpTMXAayYR+OtSfNoFlHC810bBIsntTAZGbEJZHygkwWKn8xCw8B lnR/EgUUOMT5M9SOTxTcGA9YnyquEEXkouFB1Yc+2iU7cRCKI5ftYNUJ6bapZU12sMqY /J0AkG4uKchCSmfIdlHL04/dhJYCiMSW1qBpZivK9GnG1T7oq+3Y3byLmtuK4NM+4XXS gESvE6GIoGDzy1hQ6taesoBKmOLpDp1rvCrapL3IlmcLGU+2zux153X+nR1Wxe1JqDpV qW0Q== X-Gm-Message-State: AHYfb5hcy3j9q+NRZbSHzs3sOCje6nBdHQajGKvT2oLPL5NktCievrsa DBZa8ysQwLWiKXrt X-Received: by 10.36.161.14 with SMTP id y14mr2146243ite.181.1503363192315; Mon, 21 Aug 2017 17:53:12 -0700 (PDT) Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id f11sm575126itf.1.2017.08.21.17.53.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Aug 2017 17:53:11 -0700 (PDT) From: npostavs@users.sourceforge.net To: Eli Zaretskii Subject: Re: bug#28043: [PATCH] Optimize skkdic conversion References: <87r2wi23c2.fsf@users.sourceforge.net> <831soisj5i.fsf@gnu.org> Date: Mon, 21 Aug 2017 20:54:50 -0400 In-Reply-To: <831soisj5i.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 11 Aug 2017 09:39:05 +0300") Message-ID: <87lgmcbew5.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 28043 Cc: Kenichi Handa , 28043@debbugs.gnu.org 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.7 (/) tags 28043 fixed close 28043 26.1 quit Eli Zaretskii writes: >> From: npostavs@users.sourceforge.net >> Date: Thu, 10 Aug 2017 23:25:17 -0400 >> >> While waiting for a bootstrap, I thought the skkdic conversion was >> looking a bit slow. The following patches reduce the time needed to >> less than a third of the original (2m30 to 45s measured using a >> non-optimized Emacs). The main speedup comes from optimizing >> lookup-nest-alist and set-nested-alist for the case where the key is a >> string. I suspect it might be possible to optimize even more by >> reorganizing things, but my ignorance of Japanese makes that difficult. >> >> Each commit message has the time I measured after applying. I checked >> that the generated ja-dic.el is identical to what was generated before. > > Thanks. CC'ing Handa-san, who could perhaps suggest more > optimizations. > > I guess you've verified that the results are identical after these > optimizations? If so, I see no reason not to push in a few days. Okay, I've pushed to master. [1: 9d7973530f]: 2017-08-21 20:52:25 -0400 Optimize skkdic conversion (Bug#28043) http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=9d7973530f912c6001445ba9b83b7893b466aee8 From unknown Tue Aug 19 09:59: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: Tue, 19 Sep 2017 11:24:04 +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